hatchergraphics Posted July 5, 2010 Share Posted July 5, 2010 Hi! I'm having a problem inserting html form data into my database (using variables). How should I solve this problem? The HTML form: <pre> <form action="mysql.php" method="post"> <input name="firstname" type="text" value="First Name"><br/> <input name="lastname" type="text" value="Last Name"><br/> <input name="email" type="text" value="Email"><br/> <input name="age" type="text" value="Age"><br/> <input type="submit"> </form> </pre> The PHP/MySQL: <pre> //MySQL Database connection mysql_connect("localhost", "eric", "eric") or die(mysql_error()); mysql_select_db("zabboh") or die(mysql_error()); //Fetch HTML form data $fname = $_POST['firstname']; $lname = $_POST['lastname']; $email = $_POST['email']; $age = $_POST['age']; //Insert Form Data into Database mysql_query("INSERT INTO users (fname, lname, email, age) VALUES('$fname', '$lname', '$email', '$age') ") or die(mysql_error()); </pre> Thanks in advance!! Link to comment https://forums.phpfreaks.com/topic/206749-insert-variables-into-mysql/ Share on other sites More sharing options...
phpchamps Posted July 5, 2010 Share Posted July 5, 2010 whts the problem?? r u getting any error message? Link to comment https://forums.phpfreaks.com/topic/206749-insert-variables-into-mysql/#findComment-1081216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.