Hi, I have created an HTML form so that users can enter data into the database, I need the form and the PHP code on the same page so I had to use the line in BOLD. With all the methods I used I keep getting an error.
Notice: Undefined variable: submit in c:\apache\htdocs\test\php\employees.php on line 21
<html>
<body>
<form method="post" action=$SERVER['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="Submit">
</form>
<?PHP
If ($submit=="Submit"){
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$sql = "INSERT INTO employees SET first='$POST[first]',last='$POST[last]',address='$POST[address]',position='$POST[address]'";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
}
?>
</body>
</html>
I have also used the following lines, but come up with the same error:
if($submit)
if(@$submit)
if ($REQUEST_METHOD=="POST")
Thanks for any help given!!!