I'm currently trying to enter data from a form in a wordpress web page into a mysql database.
here is the code from the html page on wordpress
<form action="<?php echo $_SERVER[PHP_SELF] ?>" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
i have installed the phpexec plugin and that seems to be runing fine.
when i enter data in the form and i submit it doesnt appear in the database.
My primary key seems to auto increment telling me something happened but no data appears.
thanks in advance