Hi, anyone help?!
The following code did not work on my computer with php4 and mySQL. It gave me a message:"undefined variable submit" something like that. Also "undefined PHP_SELF".What is the problem?
I try to separate this one into two file that one do just post a form and the other one recerive data, but it didn't work either. I was told:"undefined variable first" ...... so anyone help?
Thanks
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="first"><br>
Last name:<input type="Text" name="last"><br>
Address:<input type="Text" name="address"><br>
Position:<input type="Text" name="position"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
</body>
</html>