Forum Moderators: coopster

Message Too Old, No Replies

$ POST variables not assigned on Submit

         

SeanF

11:42 pm on Jul 5, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



I have a form which has been working perfectly well for one user for a couple of years. Now, I have added a new user and the form fails for that one user. (I can't see a difference in user configuration.)

The problem is that when the form is submitted using the following button:
<input type='submit' name='submit' value='Next'>

The form is submitted but it returns with no values set and does not process any of the form data. Even echoing out $_POST['submit'] returns a null value

I have placed the following code at the top of the page:
$test = $_POST['test'];
echo "test: $test<br/>";

And then placed the following code in the body of the form:
echo "Hidden Test is here: <br/>
<input type='hidden' name='test' value='Test'>";

When the page first loads "test" is NULL as one would expect.

If I place the "test" hidden input element at the top of the form and click "Next" the value of test is "Test"... correct
If I place the "test" hidden input element at the bottom of the form and click "Next" the value of test is NULL

By moving the hidden input I have found that there is a specific part of the form which is causing a problem. If the input element is before the code, "test" has a value. If it is after that code, "test" is null.

The offending code is here:
echo "
<p>Please indicate below your space preferences below. </p>
<table border=$table_border>
<tr>
<td>1st Choice: <input type='text' name='first_choice' size=15 maxlength=25> </td>
<td>2nd Choice: <input type='text' name='second_choice' size=15 maxlength=25> </td>
<td>3rd Choice: <input type='text' name='third_choice' size=15 maxlength=25> </td>
</tr>
<tr>
<td colspan='3'>
We would prefer <b><i>to</i></b> exhibit next to the following companies:
<input type='text' name='next_to' size=50 maxlength=75>
</td>
</tr>
<tr>
<td colspan='3'>
We would prefer <b><i>not to</i></b> exhibit next to the following companies:
<input type='text' name='not_next_to' size=50 maxlength=75>
</td>
</tr>
</table>
";

I can't for the life of me figure out why this is causing a problem.

Any thoughts would be greatly appreciated

Peter_S

9:14 pm on Jul 28, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



A field with a type "submit", does not have a real value. The value field is only the text showing in the button, so the value, is not passed in the form data.