Khanh Tran
Khanh Tran

Reputation: 1826

where is the submit value from in this form?

I got this script:

<?php
if (!isset($_POST) || empty($_POST)) {
    ?>
    <form name="form1" method="post" action="">
        <input type="text" name="textfield"><br />
        <input type="submit" name="Submit" value="Submit">
    </form>
    <?php
} else {
    $roughHTTPPOST = readfile("php://input");
    echo $roughHTTPPOST;
}
?>

Every time I submit the form I get a string contain both textfield and Submit value, the textfield value is pretty simple and straighforward. However I don't know where te Submit value come from? Here is a sample string return when I enter "a" character and submit form:

textfield=a&Submit=Submit25 P/S: What I mean here is the value 25 appended after 'Submit', where does it come from, the textfield value is easy to understand.

Upvotes: 1

Views: 97

Answers (2)

Ja͢ck
Ja͢ck

Reputation: 173592

The value 25 gets appended because that's the return value of readfile(), i.e. the number of bytes that were read from php://input.

echo file_get_contents('php://input');

That would give the expected output.


The value of Submit=Submit simply comes from your markup:

<input type="submit" name="Submit" value="Submit">

If you wish to remove that, simply delete the name attribute and the browser won't send it.

Upvotes: 1

Kermit
Kermit

Reputation: 34054

This is coming from:

... name="Submit" ...

Upvotes: 0

Related Questions