Hi, I am pretty new to PHP and I am having a bit of a problem. I am trying to submit some data and then insert it into a MySQL database. My question really has to do with the way forms work. Right now I have it coded as:
<html>
<body>
<form action="<?=$PHP_SELF?>" method="POST">
Enter the First Name: <input type="text" name="Fname" /> </br>
Enter the Last Name: <input type="text" name="Lname" /> </br>
Enter the Address Number: <input type="text" name="Address" /> </br>
<input type="submit" name="sumbit" value="ENTER"/>
</form>
<?php
if ($submit == "ENTER")
{
$databaseconnect = @mysql_connect("localhost", "root");
if (!$databaseconnect)
{
echo( "<p>Unable to connect to the database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("mydb"))
{
echo( "<p>Unable to locate the mydb database at this time.</p>" );
exit();
}
$sql = "INSERT INTO address SET FIRST='$Fname', LAST='$Lname', ADDRESS='$Address' ";
if (@mysql_query($sql))
{
echo("<p>Your Name and Address has been added.</p>");
}
else
{
echo("<p>Error adding submitted Name and Address: " . mysql_error() . "</p>");
}
}
?>
</body>
</html>
But it is giving me an error of:
Notice: Undefined variable: submit in c:\inetpub\wwwroot\MyWeb\address.php on line 16
Line 16 is
if ($submit == "ENTER")
Several tutorials show this example, but no of them work.
Any help is appericated. I would just like to know what I am doing wrong.
Thanks
KariAnn0