I am getting a warning like this when my .php page loads:
"Warning: Undefined variable: submit in C:/XITAMI/webpages/test2.php on line 12"
The code I am using is:
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root");
mysql_select_db("test",$db);
$sql = "INSERT INTO shop2 (Name,Address,Phone) VALUES ('$name','$address','$phone')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
} else{
// display form
?>
<form method="post" action="<?php echo $PHP_SELF?>">
Name:<input type="Text" name="name"><br>
Address:<input type="Text" name="address"><br>
Phone:<input type="Text" name="phone"><br>
<input type="submit" name="submit" value="Enter information">
</form>
<?php
} // end if
?>
I am new to PHP and I don't really know why I get this warning message. The info I enter in the database works fine however.
I use the latest PHP version, MySql and Xitami Web Server.
Can anyone help?
Thanks,
Robert