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!! Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/206749-insert-variables-into-mysql/#findComment-1081216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.