Hey guys,
I am trying to run through a tutorial and I believe that my MySQL is up and running (didn't get an error when starting the service) and I know my PHP is working (loads the Hello World and other basic test pages).
I am trying to compile this code that is actually supposed to add something into my database:
<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>
when I load the file it loads and looks great except that I see this at the top:
Notice: Undefined variable: submit in c:\inetpub\wwwroot\inputsql.php on line 4
I am assuming that its referring to the $submit call. The submit button also brings me back to a dead page and doesn't put anything into the database like its supposed to. Any ideas?