SQL database will not take PHP Form data
Posted: Fri Apr 11, 2008 10:59 pm
My PHP form data is not going into my SQL database. Is my syntax correct? My code is:
<?php
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$pass = $_POST['password'];
$repass = $_POST['retypepass'];
$street = $_POST['street'];
$phone = $_POST['phone'];
$apt = $_POST['apt'];
$city = $_POST['city'];
$state = $_POST['state'];
$birthday_month = $_POST['birthday_month'];
$birthday_day = $_POST['birthday_day'];
$birthday_years = $_POST['birthday_years'];
$gender = $_POST['gender'];
$zip = $_POST['zip'];
$question = $_POST['question'];
$answer = $_POST['answer'];
$reanswer = $_POST['reanswer'];
$registration = $_POST['registration'];
$connect = mysql_connect('my host, 'username', 'password') or die("Unable to Connect to Database<br>".mysql_error());
mysql_select_db('my host') or die("Unable to Select Database<br>".mysql_error());
mysql_query ("INSERT INTO 'user' VALUES ('$name','$lastname','$email','$pass','$repass','$street','$phone','$apt','$city','$birthday_month','$birthday_day','$birthday_year','$gender','$zip','$question','$answer','$reanswer','$registration')");
mysql_close($connect) or die("Unable to Close Database<br>".mysql_error());
echo " Your Information has been successfully added to the database. Thank you for your registration.;
?>
****** Please note, I replaced my host, username and password with generic info.
<?php
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$pass = $_POST['password'];
$repass = $_POST['retypepass'];
$street = $_POST['street'];
$phone = $_POST['phone'];
$apt = $_POST['apt'];
$city = $_POST['city'];
$state = $_POST['state'];
$birthday_month = $_POST['birthday_month'];
$birthday_day = $_POST['birthday_day'];
$birthday_years = $_POST['birthday_years'];
$gender = $_POST['gender'];
$zip = $_POST['zip'];
$question = $_POST['question'];
$answer = $_POST['answer'];
$reanswer = $_POST['reanswer'];
$registration = $_POST['registration'];
$connect = mysql_connect('my host, 'username', 'password') or die("Unable to Connect to Database<br>".mysql_error());
mysql_select_db('my host') or die("Unable to Select Database<br>".mysql_error());
mysql_query ("INSERT INTO 'user' VALUES ('$name','$lastname','$email','$pass','$repass','$street','$phone','$apt','$city','$birthday_month','$birthday_day','$birthday_year','$gender','$zip','$question','$answer','$reanswer','$registration')");
mysql_close($connect) or die("Unable to Close Database<br>".mysql_error());
echo " Your Information has been successfully added to the database. Thank you for your registration.;
?>
****** Please note, I replaced my host, username and password with generic info.