Fabio9999 Posted December 12, 2008 Share Posted December 12, 2008 Hello there, I have tried to create a registration form for Users to register. I have run through the code multiple times and I have been a witness to a strange phenomena. Allthough it insists that registration succeeded however there is no entries in the database. this is my src. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?PHP error_reporting(E_ALL); // register2.php include("config.php"); $errors = ""; if (!isset($_POST['title'])) $errors .= "Please provide a title. <br/>"; if (!isset($_POST['first_name'])) $errors .= "Please provide a firstname. <br/>"; if (!isset($_POST['surname'])) $errors .= "Please provide a surname. <br/>"; if (!isset($_POST['street'])) $errors .= "Please provide a street. <br/>"; if (!isset($_POST['town'])) $errors .= "Please provide a town. <br/>"; if (!isset($_POST['county'])) $errors .= "Please provide a county. <br/>"; if (!isset($_POST['postcode'])) $errors .= "Please provide a postcode. <br/>"; if (!isset($_POST['email_adress'])) $errors .= "Please provide an email adress. <br/>"; if ($errors == "") { $sql= "INSERT INTO customer_webair (id, title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )" or die(mysql_error()); echo "Registration Successful!"; } else { echo $errors."Please go back and try again."; } ?> </body> </html> Thanks a lot any hints appreciated. Fabio Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/ Share on other sites More sharing options...
will_1990 Posted December 12, 2008 Share Posted December 12, 2008 did you get any errors while connecting to the database? Did you ensure that you used the right table name? Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713249 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 is your field `id` in the database auto increment? Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713251 Share on other sites More sharing options...
Fabio9999 Posted December 12, 2008 Author Share Posted December 12, 2008 is your field `id` in the database auto increment? Yes it is. @Will1990: Yes database & tablename are correct and I checked on the case sensitivity. "Column Count Doesn't Match Value Count At Row 1" was the only error I received previously but I managed to get rid of it by myself. Thanks for both of your replies. Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713262 Share on other sites More sharing options...
dc277 Posted December 12, 2008 Share Posted December 12, 2008 Your problem with your script is that you didn't actually run the INSERT command. Around your Insert command/string, don't forget to use mysql_query(-datahere-); Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713263 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 change this $sql= "INSERT INTO customer_webair (id, title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )" or die(mysql_error()); to this $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713270 Share on other sites More sharing options...
Fabio9999 Posted December 12, 2008 Author Share Posted December 12, 2008 change this $sql= "INSERT INTO customer_webair (id, title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )" or die(mysql_error()); to this $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', I changed that but now I get an error in the line following " )") or die(mysql_error());" echo "Registration Successful!" } else { echo $errors."Please go back and try again."; } ?> Thanks for your help so far, I really appreciate it Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713279 Share on other sites More sharing options...
dc277 Posted December 12, 2008 Share Posted December 12, 2008 What does the error say? Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713283 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 can you repost the code you're currently using and the error you got Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713284 Share on other sites More sharing options...
Fabio9999 Posted December 12, 2008 Author Share Posted December 12, 2008 The error I received: Parse error: syntax error, unexpected ')' in /nas/students/f/fmuller/unix/public_html/register2.php on line 44 Code used: <?php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?PHP error_reporting(E_ALL); // register2.php include("config.php"); $errors = ""; if (!isset($_POST['title'])) $errors .= "Please provide a title. <br/>"; if (!isset($_POST['first_name'])) $errors .= "Please provide a firstname. <br/>"; if (!isset($_POST['surname'])) $errors .= "Please provide a surname. <br/>"; if (!isset($_POST['street'])) $errors .= "Please provide a street. <br/>"; if (!isset($_POST['town'])) $errors .= "Please provide a town. <br/>"; if (!isset($_POST['county'])) $errors .= "Please provide a county. <br/>"; if (!isset($_POST['postcode'])) $errors .= "Please provide a postcode. <br/>"; if (!isset($_POST['email_adress'])) $errors .= "Please provide an email adress. <br/>"; if ($errors == "") { $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )") or die(mysql_error()); echo "Registration Successful!" } else { echo $errors."Please go back and try again."; } ?> </body> </html> Thanks lads Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713289 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 try this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?PHP error_reporting(E_ALL); // register2.php include("config.php"); $errors = ""; if (!isset($_POST['title'])) $errors .= "Please provide a title. <br/>"; if (!isset($_POST['first_name'])) $errors .= "Please provide a firstname. <br/>"; if (!isset($_POST['surname'])) $errors .= "Please provide a surname. <br/>"; if (!isset($_POST['street'])) $errors .= "Please provide a street. <br/>"; if (!isset($_POST['town'])) $errors .= "Please provide a town. <br/>"; if (!isset($_POST['county'])) $errors .= "Please provide a county. <br/>"; if (!isset($_POST['postcode'])) $errors .= "Please provide a postcode. <br/>"; if (!isset($_POST['email_adress'])) $errors .= "Please provide an email adress. <br/>"; if ($errors == "") { $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."', )") or die(mysql_error()); echo "Registration Successful!"; } else { echo $errors."Please go back and try again."; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713291 Share on other sites More sharing options...
Fabio9999 Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks gevans. I used the code and I got an error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 11" Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713293 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 we're getting there slowly <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?PHP error_reporting(E_ALL); // register2.php include("config.php"); $errors = ""; if (!isset($_POST['title'])) $errors .= "Please provide a title. <br/>"; if (!isset($_POST['first_name'])) $errors .= "Please provide a firstname. <br/>"; if (!isset($_POST['surname'])) $errors .= "Please provide a surname. <br/>"; if (!isset($_POST['street'])) $errors .= "Please provide a street. <br/>"; if (!isset($_POST['town'])) $errors .= "Please provide a town. <br/>"; if (!isset($_POST['county'])) $errors .= "Please provide a county. <br/>"; if (!isset($_POST['postcode'])) $errors .= "Please provide a postcode. <br/>"; if (!isset($_POST['email_adress'])) $errors .= "Please provide an email adress. <br/>"; if ($errors == "") { $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."' )") or die(mysql_error()); echo "Registration Successful!"; } else { echo $errors."Please go back and try again."; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713295 Share on other sites More sharing options...
Fabio9999 Posted December 12, 2008 Author Share Posted December 12, 2008 we're getting there slowly <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?PHP error_reporting(E_ALL); // register2.php include("config.php"); $errors = ""; if (!isset($_POST['title'])) $errors .= "Please provide a title. <br/>"; if (!isset($_POST['first_name'])) $errors .= "Please provide a firstname. <br/>"; if (!isset($_POST['surname'])) $errors .= "Please provide a surname. <br/>"; if (!isset($_POST['street'])) $errors .= "Please provide a street. <br/>"; if (!isset($_POST['town'])) $errors .= "Please provide a town. <br/>"; if (!isset($_POST['county'])) $errors .= "Please provide a county. <br/>"; if (!isset($_POST['postcode'])) $errors .= "Please provide a postcode. <br/>"; if (!isset($_POST['email_adress'])) $errors .= "Please provide an email adress. <br/>"; if ($errors == "") { $sql= mysql_query("INSERT INTO customer_webair (title,first_name, surname, street, town, county, postcode, email_adress) VALUES( '".addslashes($_POST['title'])."', '".addslashes($_POST['first_name'])."', '".addslashes($_POST['surname'])."', '".addslashes($_POST['street'])."', '".addslashes($_POST['town'])."', '".addslashes($_POST['county'])."', '".addslashes($_POST['postcode'])."', '".addslashes($_POST['email_adress'])."' )") or die(mysql_error()); echo "Registration Successful!"; } else { echo $errors."Please go back and try again."; } ?> </body> </html> Thanks dude its finally working i love you man (no homo) Cheers Fabio Link to comment https://forums.phpfreaks.com/topic/136602-solved-user-registration-formgot-a-few-small-errors/#findComment-713298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.