Okay, this is an easy one I'm sure but I can't figure out what I'm doing wrong.
I have a simple table setup in MYSQL to hold name, address, city, state, & zip.
Below is the PHP file that I'm using to input the data. I tried it and it's not inserting the data into the database. I got this script from one of the columns on this site. What am I doing wrong?
The field names match the column names in my database.
<HEAD>
<TITLE>Input Data Page</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post" action=" <?php echo $PHP_SELF ?>">
Name<br>
<input type="Text" name="name" size="50">
<br>
Address<br>
<input type="Text" name="address" size="50">
<br>
City<br>
<input type="Text" name="city" size="25">
<br>
State<br>
<input type="Text" name="state" size="25">
<br>
Zip<br>
<input type="Text" name="zip" size="25">
<br>
<input type="submit" name="submit" value="Upload">
</form>
<?
if ($submit) {
$dbh=mysql_connect("localhost","myusername","mypassword");
mysql_select_db("databasename",$dbh);
$sql = "INSERT INTO tablename (name,address,city,state,zip) ".
"VALUES ('$name,$address,$city,$state,$zip')";
/This part displays what you just entered
echo "Name: $name<br>\n";
echo "Address: $address<br>\n";
echo "City: $city<br>\n";
echo "State: $state<br>\n";
echo "Zip: $zip<br>\n";
echo "<br>\n";
}
?>
</BODY>
Thanks in Advance
-Andrew