SirChick Posted August 1, 2007 Share Posted August 1, 2007 When i submit the registration details only 2 variables submit to the database... that is IP and gender. The others come out as blank but it does insert... heres my code: <?php error_reporting(E_ALL); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } If ($jump2 ==1){ mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSERNAME->Username) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_object($chkEmail); if($_POST['EmailRegistration'] == $getEmail->Email) { die('Email already registered, please choose a different username!'); } If ($Password == $Password2) { mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; echo $query; mysql_query($query) or die(mysql_error()); } } } ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 1, 2007 Author Share Posted August 1, 2007 im thinking its to do with my string escape ? but i duno ? Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 1, 2007 Share Posted August 1, 2007 try to echo the query to know if your actually getting something echo $query; and show us the result Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 1, 2007 Author Share Posted August 1, 2007 Notice: Undefined index: TermsOfService in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 5 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 8 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 8 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 10 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 10 Unknown database 'civilian' How ever it does connect im positive of that nothing has changed in the connect thing. Also just to add have u noticed in the warning error it says: mysql_real_escape_string() [function.mysql-real-escape-string] and my variable declaration doesnt have the () not the one in the [] type brackets.. could that be why ? Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 1, 2007 Share Posted August 1, 2007 try ot remove first that mysq_real scape thing and tell us the result Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 1, 2007 Author Share Posted August 1, 2007 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 27 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 32 INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('davedave', 'davedave', 'dave@dave.com', 'United Kingdom', '127.0.0.1', 'Male') NOTE: The data has inputted even though this error shows up... but at least the data is now inputting but im vulnerable to attacks. Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 1, 2007 Share Posted August 1, 2007 try this first <?php error_reporting(E_ALL); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } if ($jump2 ==1){ mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSERNAME->Username) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_object($chkEmail); if($_POST['EmailRegistration'] == $getEmail->Email) { die('Email already registered, please choose a different username!'); } if ($Password == $Password2) { mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); } } } ?> i just indent your code properly and little change tell me the error if there is Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 1, 2007 Author Share Posted August 1, 2007 Gah it keeps giving different errors we are back with that big longgg error as i already posted earlier Notice: Undefined index: TermsOfService in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 5 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 8 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 8 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 10 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Administrator\My Documents\Xampp\htdocs\RegisterPage.php on line 10 Unknown database 'civilian' Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 [code]try <?php error_reporting(E_ALL); if(!mysql_connect("localhost", "root", "private")){ echo mysql_error(); exit; } esle{ mysql_select_db("civilian") or die (mysql_error()); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } if ($jump2 ==1){ $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSERNAME->Username) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_object($chkEmail); if($_POST['EmailRegistration'] == $getEmail->Email) { die('Email already registered, please choose a different username!'); } if ($Password == $Password2) { $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); } } } } ?> [/code] and paste the error Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 im using apache server by the way just so you know. duno if that matters? Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\RegisterPage.php on line 5 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\RegisterPage.php on line 5 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\RegisterPage.php on line 6 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\RegisterPage.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\RegisterPage.php on line 8 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\RegisterPage.php on line 8 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 25 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 30 Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 remove the mysql_real_escape_string() to test the prob and the last two errors maybe saying that the query failed Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 Before i do, the error decided to stop appearing :S and now i only get this: Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 10 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 29 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 34 i think the terms of service thing is because i have it checking if its "off" which could be the wrong value to use but im unsure? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 2, 2007 Share Posted August 2, 2007 Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 10 Means that you're trying to access an element in an array that doesn't exist. Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 29 More than likely this query failed: $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); change it to: $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'") or die(mysql_error()); Then see what the error is. Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 same response Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 10 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 29 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 34 Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 i will remove the string escape now and see if it changes result is the same : Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 10 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 29 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 34 Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 if ($jump2 ==1){ $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_assoc($chkUSERNAME); if($_POST['Username'] == $getUSERNAME['Username']) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_assoc($chkEmail); if($_POST['EmailRegistration'] == $getEmail['Email']) { die('Email already registered, please choose a different username!'); } if ($Password == $Password2) { $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); } Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 10 look carefully if this is the name of the form TermsOfService it says it not part of the post array or to be sure do this print_r($_POSt); all the forms will be displayed see if that will apear "TermsOfService " and use assoc or array it will not display an error if the query fails just like object does Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 2, 2007 Share Posted August 2, 2007 If you are going to use mysql_real_escape_string, you must connect to the DB first. <?php error_reporting(E_ALL); mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } else { $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'") or die(mysql_error()); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSERNAME->Username) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'") or die(mysql_error()); $getEmail = mysql_fetch_object($chkEmail); if($_POST['EmailRegistration'] == $getEmail->Email) { die('Email already registered, please choose a different username!'); } $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; echo $query; mysql_query($query) or die(mysql_error()); } } ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 If you are going to use mysql_real_escape_string, you must connect to the DB first. <?php error_reporting(E_ALL); mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("civilian") or die (mysql_error()); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } else { $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'") or die(mysql_error()); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSERNAME->Username) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'") or die(mysql_error()); $getEmail = mysql_fetch_object($chkEmail); if($_POST['EmailRegistration'] == $getEmail->Email) { die('Email already registered, please choose a different username!'); } $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; echo $query; mysql_query($query) or die(mysql_error()); } } ?> That produced this: Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 9 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 30 Notice: Trying to get property of non-object in C:\xampp\htdocs\RegisterPage.php on line 37 INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('tester243', 'tester', 'test@hg.com', 'United Kingdom', '127.0.0.1', 'Male') would you like me to provide the html if that would help ? Quote Link to comment Share on other sites More sharing options...
teng84 Posted August 2, 2007 Share Posted August 2, 2007 try <?php error_reporting(E_ALL); if(!mysql_connect("localhost", "root", "private")){ echo mysql_error(); exit; } esle{ mysql_select_db("civilian") or die (mysql_error()); if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } if ($jump2 ==1){ $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_assoc($chkUSERNAME); if($_POST['Username'] == $getUSERNAME['Username']) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_assoc($chkEmail); if($_POST['EmailRegistration'] == $getEmail['Email']) { die('Email already registered, please choose a different username!'); } if ($Password == $Password2) { $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); } } } } ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 Now only this shows up. Notice: Undefined index: TermsOfService in C:\xampp\htdocs\RegisterPage.php on line 9 And also now if the terms of service is not checked it still submits.. when it should be saying "you have not agreed to terms of service" when ever the check box is unticked. Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted August 2, 2007 Share Posted August 2, 2007 try this code <?php error_reporting(E_ALL); if(!mysql_connect("localhost", "root", "private")): echo mysql_error(); exit; else: mysql_select_db("civilian") or die (mysql_error()); # Check all post data print_r($_POST); exit; # debugging purpose: remove after checking if (isset($_POST['RegistrationSubmission'])): $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if($_POST['TermsOfService'] == 'off'): echo "You must agree to the terms of service before registering!"; $jump2 = 0; elseif($Password != $Password2): echo "Passwords did not match"; $jump2 = 0; elseif($jump2 == 1): $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); if(mysql_num_rows($chkUSERNAME) != 0): die('Username already registered, please choose a different username!'); endif; $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); if(mysql_num_rows($chkEmail) != 0): die('Email already registered, please choose a different username!'); endif; if ($Password == $Password2): $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); endif; endif; endif; endif; ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 try this code <?php error_reporting(E_ALL); if(!mysql_connect("localhost", "root", "private")): echo mysql_error(); exit; else: mysql_select_db("civilian") or die (mysql_error()); # Check all post data print_r($_POST); exit; # debugging purpose: remove after checking if (isset($_POST['RegistrationSubmission'])): $TermsOfService = $_POST['TermsOfService']; $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $jump2 = 1; if($_POST['TermsOfService'] == 'off'): echo "You must agree to the terms of service before registering!"; $jump2 = 0; elseif($Password != $Password2): echo "Passwords did not match"; $jump2 = 0; elseif($jump2 == 1): $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); if(mysql_num_rows($chkUSERNAME) != 0): die('Username already registered, please choose a different username!'); endif; $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); if(mysql_num_rows($chkEmail) != 0): die('Email already registered, please choose a different username!'); endif; if ($Password == $Password2): $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); endif; endif; endif; endif; ?> All that displays on the page was : Array ( ) didnt even load the html etc Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 Just thought id bump this with some updated news! I have put a captcha security php code into my registration aswell (to make life more complex, but everyone kept shouting at me for not putting one in so i put one in and now it still doesn't work but it's all re-arranged a bit. I have it displaying correctly, how ever if i input and invalid captcha it doesn't produce and error and if i produce a correct captcha it doesnt submit the data to the database at all so no record is made in the table. This was my attempted: <?php error_reporting(E_ALL); if(!mysql_connect("localhost", "root", "private")){ echo mysql_error(); exit; } else{ mysql_select_db("civilian") or die (mysql_error()); if (isset($_POST['RegistrationSubmission'])) { session_start(); if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $TermsOfService = $_POST['TermsOfService']; $jump2 = 1; if ($Password != $Password2) { echo "Passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; $jump2 = 0; } } if ($jump2 ==1){ $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_assoc($chkUSERNAME); if($_POST['Username'] == $getUSERNAME['Username']) { die('Username already registered, please choose a different username!'); } $chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'"); $getEmail = mysql_fetch_assoc($chkEmail); if($_POST['EmailRegistration'] == $getEmail['Email']) { die('Email already registered, please choose a different username!'); } if ($Password == $Password2) { $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')"; mysql_query($query) or die(mysql_error()); unset($_SESSION['security_code']); header("Location: success.php"); } // Insert your code for showing an error message here If ($_SESSION['security_code'] != $_POST['security_code']){ die('Your security code input did not match the generated image, please try again!'); }} } } } ?> This is the captcha code: <?php session_start(); class CaptchaSecurityImages { var $font = 'monofont.ttf'; function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function CaptchaSecurityImages($width='120',$height='40',$characters='6') { $code = $this->generateCode($characters); /* font size will be 75% of the image height */ $font_size = $height * 0.75; $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream'); /* set the colours */ $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); /* generate random dots in background */ for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } /* generate random lines in background */ for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } /* create textbox and add text */ $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); /* output captcha image to browser */ header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; } } $width = isset($_GET['width']) && $_GET['height'] < 600 ? $_GET['width'] : '120'; $height = isset($_GET['height']) && $_GET['height'] < 200 ? $_GET['height'] : '40'; $characters = isset($_GET['characters']) && $_GET['characters'] > 2 ? $_GET['characters'] : '6'; $captcha = new CaptchaSecurityImages($width,$height,$characters); ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 bumpy ??? Quote Link to comment Share on other sites More sharing options...
SirChick Posted August 2, 2007 Author Share Posted August 2, 2007 where did everyone go ? Quote Link to comment 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.