I have this problem with phpMyAdmin. I've set up my simple php and mysql scripts and everything works fine. It connects to my mysql database(remote with my hosting provider) and it does actually insert all the required fields into the database. the problem is that the fields are all blank. there is nothing in them. here is my code:
<?php
$con = mysql_connect("myserverip","mydatabasename","my password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydatabasename", $con);
$sql="INSERT INTO nametable (firstname, lastname) VALUES('$_POST[firstname]','$_POST[lastname]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
The html is very simple, just two input fields with first name and last name:
The html:
<html>
<body>
<h1>A small example page to insert some data in to the MySQL database using PHP</h1>
<form action="insert.php" method="post">
Firstname: <input type="text" name="fname" /><br><br>
Lastname: <input type="text" name="lname" /><br><br>
<input type="submit" />
</form>
</body>
</html>
All help is appreciated.