I know the problem, I just scoured google and w3schools and other sites and they all have done the exact same thing I have, and for some reason mine won't accept the data. Any help is much appreciated.
Currently it adds an entry to my database, but the values are blank. And I am in total understanding that my variables are not getting any value put into them. What I don't understand is why? Every where I looked, I even copied and pasted code from other sites to try it, and it still didn't work. The one I have below is virtually an exact copy from w3schools and it still won't work. Any insight?
<html> <body> <form action="reg.php" method="post"> Firstname: <input type="text" name="firstname"> Lastname: <input type="text" name="lastname"> Age: <input type="text" name="age"> <input type="submit"> </form> </body> </html>
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$age = $_POST['age'];
$con = mysql_connect("127.0.0.1","root","");
mysql_select_db("my_db");
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$firstname','$lastname','$age')";
$result = mysql_query($sql);
if ($result)
{
echo "1 record added";
}
else{
echo "Did not work";
}
mysql_close($con);
?>
I am starting to wonder if it is an issue with my database.
As when the record adds, I still don't get the echo or print statements.

New Topic/Question
Reply



MultiQuote





|