Hi,
I've tried several tutorials and can't seem to input data into my database. I can query my databases just fine and see all the current records, but when I hit the Submit button, all that happens is the form clears (but nothing ever makes it back to the database.)
Here's one I'm trying (this one's from a Webmonkey tutorial):
<html>
<body>
<?php
if ($submit) {
// process form
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("webmonkey",$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>
Any ideas what I'm doing wrong? Thanks.