Here is the html form:
<form action="process.php" method="post">
<label> Enter Email:</label><input type="text" name="email"/>
</form>
Here is the php:
<?
$email=$_POST['email'];
mysql_connect("localhost", "root", "password" ) or die(mysql_error());
mysql_select_db("data") or die(mysql_error());
mysql_query("INSERT INTO `data` VALUES ('$email')");
?>
What am I doing wrong?
There are a lot of things to comment on, but the specific cause of your error is case sensitivity. Your field name is Email
but you are looking for email
in the $_POST
superglobal.
So
$email=$_POST['email'];
should be
$email=$_POST['Email'];
As for the other stuff, you are wide open to SQL injections and using an obsolete API. I strongly recommend fixing this before pushing your code to production.