having an issue--*cough*newbie*cough*--the html and php code here supposedly creates a new record into my database. problem is, the successfully connects to sql and creates the record, but the contents of the $_POST variables do not make it into their respective fields. I have an id field (AUTO_INCREMENT) that is created successfully, but no text in the mailto, firstname, and lastname fields.
any comments would be most appreciated....
<html>
<head>
<title>Bee In The Buzz</title>
</head>
<body>
<p>Are you a:
<form method="post" action="form2sql.php">
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" name="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" name="lastname"><BR>
<LABEL for="mailto">email: </LABEL>
<INPUT type="text" name="mailto"><BR>
<input type="submit" name="Submit"/>
</form>
</body>
</html>
form2sql.php:
<?php
$hostname="***";
$username="***";
$password="***";
$dbname="testdog";
$usertable="emails";
$con = mysql_connect($hostname,$username, $password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("testdog", $con);
$sql="use emails";
$sql="INSERT INTO emails (mailto, firstname, lastname)
VALUES
('$_POST[mailto]','$_POST[firstname]','$_POST[lastname]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>