Forum Moderators: coopster

Message Too Old, No Replies

PHP 5 form field values not passing

data from forms not passing over to the next page on php5 but work on php4

         

zerokarma

2:01 pm on Mar 19, 2007 (gmt 0)

10+ Year Member



I seem to be having a problem passing data from a form field in PHP5. In PHP4 the code works with out problem but in PHP5 none of the values the user entered gets transfered over to the next page. Does anyone know what might be causing this to happen?

Say for example I have this form:


<form name=searchFormMaker method=post action="search_country.php">
<b>Search by Country:</b><br>
<select name="Country">
<option selected value="All">All Countries</option>
<option value="Canada">Canada</option>
<option value="United Kingdom">United Kingdom
<option value="United States">United States
</select>
<input type=submit name=Submit value="Search">
</form>

Then on the next page I try to output that data:


<?
echo $Country;
?>

Whatever the user selected for country will not be displayed, I just get a blank under PHP5. Yet if I test the same code under PHP4 it works without any problem.

Does anyone know what might be going on here?

coopster

2:03 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, zerokarma.

It is almost certain to be a register_globals [php.net] issue.

dreamcatcher

2:05 pm on Mar 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi zerokarma,

A warm welcome to Webmaster World. :)

register_globals [php.net] is set to off by default in PHP5 for security. You need to access your vars using the $_POST array:

echo $_POST['Country'];

dc

edit:Coop beat me to it.