NYCPHP Meetup

NYPHP.org

Question

Larry Chuon LarryC at indexstock.com
Mon Jun 10 17:18:55 EDT 2002


I'm working on a sample code and have some questions.  My php and html files
are below.  I'm running on IIS and MySQL.  This code gives me the following
error:
 
 
Notice: Undefined variable: first in d:\\example\\datain.php on line 5

Notice: Undefined variable: last in d:\\example\\datain.php on line 5

Notice: Undefined variable: nickname in d:\\example\\datain.php on line 5

Notice: Undefined variable: email in d:\\example\\datain.php on line 5

Notice: Undefined variable: salary in d:\\example\\datain.php on line 5
Thank you! Information entered. 
 
If I add the following lines prior to the insert statement, it works fine.
$first = $HTTP_POST_VARS['first'];

$last = $HTTP_POST_VARS['last'];

$nickname = $HTTP_POST_VARS['nickname'];

$email = $HTTP_POST_VARS['email'];

$salary = $HTTP_POST_VARS['salary'];

Why do I need $HTTP_POST_VARS???? Thanks in advance.
 
--------------------
 
datain.php
<html>

<?php

$db = mysql_connect("172.21.6.25","root","123456");

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.\
";

?>

</html>

 
datain.html
<html>

<body>

<form action="datain.php" method="post">

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>

</body>

</html> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20020610/0663db55/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Ivy.gif
Type: image/gif
Size: 5665 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20020610/0663db55/attachment.gif>


More information about the talk mailing list