Click to See Complete Forum and Search --> : [Resolved] Variables are not automatically getting the values as filled in the html form


avneet
07-24-2004, 03:01 PM
I just started connecting PHP5 with mysql 5.0.0-alpha.
i had made a html file with the following code:
<HTML>
<BODY>
<form method="post" action="detain.php">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Nick Name:<input type="Text" name="nickname"><br>
E-mail:<input type="Text" name="email"><br>
Salary:<input type="Text" name="salary"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
</HTML>

Then i had coded the relavant detain.php with the following code:
<HTML>
<?php
$db = mysql_connect("localhost", "root","");
mysql_select_db("learndb",$db);
$sql = "INSERT INTO personnel (firstname, lastname, nick, email, salary) VALUES ('$first','$last','$nickname','$email','salary')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
?>
</HTML>

The problem i am facing is that no values are stored in the variables $first, $last, $nickname,$email,$salary and hence, a simple blank row is inserted in the database.

Can anybody help me in finding out why aren't the values from the form are automatically stored in the variables with the same name as of the fields?

Thanks,
Avneet

tekky
07-24-2004, 03:20 PM
try reading about $_POST here... (http://www.php.net/manual/en/language.variables.predefined.php)

avneet
07-25-2004, 02:25 AM
Thanks Karl.
After setting "register_globals = On" in the php.ini file, i was able to resolve the problem.

Weedpacket
07-25-2004, 03:32 AM
Originally posted by avneet
Thanks Karl.
After setting "register_globals = On" in the php.ini file, i was able to resolve the problem. *****BZzzzzt!! Wrong answer!
For related information on this change, read the configuration entry for register_globals, the security chapter on Using Register Globals , as well as the PHP 4.1.0 and 4.2.0 Release Announcements.

Using the available PHP Reserved Predefined Variables, like the superglobal arrays, is preferred.

planetsim
07-25-2004, 05:06 AM
Since when did the PHP 5 forum become Wheel of Fortune :D