Page 1 of 1
php form values into a databse
Posted: Fri Jul 16, 2010 12:47 pm
by heshan
Can anyone knows how to insert date of birth and gender values of a particular user into the database?
They are included in a registration form.
Thank You,
Heshan.
Re: php form values into a databse
Posted: Fri Jul 16, 2010 3:40 pm
by buckit
theform.htm
Code: Select all
<form method='post' action='usetheform.php'>
<input type='text' name='dob'>
<input type='text' name='gender'>
<input type='submit' name='submit'>
</form
usetheform.php
Code: Select all
//open database connection
//set variables from form (this is a good time to sanitize them (google 'php sanitize form input'))
$dob = $_POST['dob'];
$gender= $_POST['gender'];
//execute this sql statement
INSERT INTO users (dob,gender) VALUES ({$dob}, {$gender}
again... google 'php sanitize form input'. or search here on the forums.
If you dont know how to get a connection to your DB then go to
http://www.w3schools.com/PHP/php_mysql_connect.asp.
this should help you in the right direction.