Submit with value in button verse input (PhpED behaviour)

34 Views Asked by At

I have the following forms. I would have expected identical results for both forms (except for the data value of course).

Is there anything wrong with the second form and its use of a button with the name/value pair?

The reason I ask is when running the code using PhpED IDE, it responds with the value of $_POST['task2'] equal to "SUBMIT" and not "save".

EDIT. Upon further investigation, I have found that IE7 (emulated using IE 10) has the same behavior. That being the case, it seems bad practice to use a button with name/pair if you care about IE7. True?

<?php
echo('<pre>'.print_r($_POST,1).'</pre>');
?>
<form method='post' action='' name='form1'>
    <button type="submit">SUBMIT</button>
    <input type="hidden" name="task1" value="save" />
    <input type="text" name="data1" value="test1" />
</form>

<form method='post' action='' name='form2'>
    <button type="submit" name="task2" value="save">SUBMIT</button>
    <input type="text" name="data2" value="test2" />
</form>
0

There are 0 best solutions below