RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Yup .. This is that chunk of lines //Tell the script that something went wrong $pass = FALSE; } //If something went wrong, send them back to fix their mistakes if ($pass == FALSE) { die(); //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } else { //They have entered all the required information //Their username, password, and email are acceptable Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242910 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Well, then do you know what that tells us? It tells us that I am a dumb...... Anyways, I found the problem.... The die() in the if statement tells us that for some reason $pass = FALSE. The problem is, none of our checks told it to be false. Where did I go wrong? I forgot that a variable that is not set, is false. Because of that, the value of $pass in always false until other wise stated. The fix is simple, reverse it... Replace your check.php with this: <?php //Start the session session_start(); //Database Information //Username? $database_username = "root"; //Your password? $database_password = ""; //The name of the database you are trying to connect to $database_database = "main"; //Did the user enter a username? if (strlen($_POST['username']) < 4) { //There username contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a password? if (strlen($_POST['password']) < 4) { //There password contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a email address? if (strlen($_POST['email']) < { //There email contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { //Their username contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9]/", $_POST['password'])) { //Their password contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_.@-]/", $_POST['email'])) { //Their email contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //For added security, MD5 their passwords before you compare them $md5_password = md5($_POST['password']); $md5_varpassword = md5($_POST['varpassword']); //For the users benefit, make sure their passwords match if ($md5_password != $md5_varpassword) { //There passwords did not match //Set a session variable so that you can tell the user how they screwed up $_SESSION['match_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //If something went wrong, send them back to fix their mistakes if ($pass == TRUE) { //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } else { //They have entered all the required information //Their username, password, and email are acceptable //For the users protection, you should always encrypt their passwords $password = md5($_POST['password']); //You now have all their info, you may put them into the database //Connect to the database $connect = mysql_connect('localhost',$username,$password) or die(mysql_error()); //Select your database mysql_select_db($database) or die(mysql_error()); //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); //Close mysql mysql_close(); //They are now signed up //Tell them that they are now signed up echo "Congratulations, you are now signed up!"; //Send them back to the home page echo "<meta http-equiv=\"refresh\" content=\"6;url=index.php\">"; //Offer an optional link in case the transfer doesn't work echo "<a href=\"index.php\">If you are not transfered in 10 seconds, click here</a>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242917 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 You being dumb has happened alot in this thread, huh lol Now I get this: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: YES) in C:\xampplite\htdocs\xampp\site\check.php on line 137 Access denied for user 'ODBC'@'localhost' (using password: YES) Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242920 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Its for this line: //Connect to the database $connect = mysql_connect ('localhost',$username,$password) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242922 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Well, that is self explanatory. It means your where unable to connect to the database because your not authorized. This normally means that your username or password is incorrect. In this case, it is my fault once again! use this: <?php //Start the session session_start(); //Database Information //Username? $database_username = "root"; //Your password? $database_password = ""; //The name of the database you are trying to connect to $database_database = "main"; //Did the user enter a username? if (strlen($_POST['username']) < 4) { //There username contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a password? if (strlen($_POST['password']) < 4) { //There password contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['short_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Did the user enter a email address? if (strlen($_POST['email']) < { //There email contains less than 4 characters //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { //Their username contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_username'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9]/", $_POST['password'])) { //Their password contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //Make sure they aren't trying to hack you if (preg_match("/[^a-zA-Z0-9_.@-]/", $_POST['email'])) { //Their email contains invalid characters //They me be trying to hack you... //Set a session variable so that you can tell the user how they screwed up $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //For added security, MD5 their passwords before you compare them $md5_password = md5($_POST['password']); $md5_varpassword = md5($_POST['varpassword']); //For the users benefit, make sure their passwords match if ($md5_password != $md5_varpassword) { //There passwords did not match //Set a session variable so that you can tell the user how they screwed up $_SESSION['match_password'] = TRUE; //Tell the script that something went wrong $pass = TRUE; } //If something went wrong, send them back to fix their mistakes if ($pass == TRUE) { //They failed the exam //For some reason they have failed or check system //You will need to send the back to fix the problem before we continue echo "<meta http-equiv=\"refresh\" content=\"1;url=signup.php\">"; //I like to kill the script at this point. die(); } else { //They have entered all the required information //Their username, password, and email are acceptable //For the users protection, you should always encrypt their passwords $password = md5($_POST['password']); //You now have all their info, you may put them into the database //Connect to the database $connect = mysql_connect('localhost',$database_username,$database_password) or die(mysql_error()); //Select your database mysql_select_db($database_database) or die(mysql_error()); //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); //Close mysql mysql_close(); //They are now signed up //Tell them that they are now signed up echo "Congratulations, you are now signed up!"; //Send them back to the home page echo "<meta http-equiv=\"refresh\" content=\"6;url=index.php\">"; //Offer an optional link in case the transfer doesn't work echo "<a href=\"index.php\">If you are not transfered in 10 seconds, click here</a>"; } ?> I forgot to update the variables.... Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242931 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Error after error after error lol ..... 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 ''username', 'password', 'email') VALUES ('ritchie', '64423c6f5ffd6a3205e0ad788ed' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242933 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Bye now you have to be wondering how I ever get anything done! Lets just say I have NEVER EVER had this many problems with a script! This is a bit of advice for you. Never write a whole script like this before testing it. When I script, I use my local server and test each part. It allows you to solve tiny problems along the way. This prevents all the tiny script errors from making you redo the entire script over and over again. Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242935 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Write this: echo $query die(); Directly below this line: $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')") or die(mysql_error()); Tell me what it prints. Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242938 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Parse error: syntax error, unexpected T_EXIT, expecting ',' or ';' in C:\xampplite\htdocs\xampp\site\check.php on line 149 Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242939 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 God! Use this instead echo $query; die(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242942 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Lol, this is a headache .. Gimme this error again .. 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 ''username', 'password', 'email') VALUES ('ritchie', '64423c6f5ffd6a3205e0ad788ed' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242943 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 OK, use this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = "INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')" echo $query; die(); mysql_query($query) or die(mysql_error()); //Close mysql mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242944 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 OMG! lol Parse error: syntax error, unexpected T_ECHO in C:\xampplite\htdocs\xampp\site\check.php on line 148 Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242952 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Thats what I thought.... Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')"); echo "<br /><br />" . $query . "<br /><br />"; die(); //Close mysql mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242955 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Goes to check.php and stays. Its blank and nothing added to db Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242956 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Ok, something happened to my script change when I posted it Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('" . $username . "', '" . $password . "', '" . $email . "')"); echo "<br /><br />" . $query . "<br /><br />"; die(); //Close mysql mysql_close(); Try that. That is what you should have tried but I think it got messed up some how.... Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242962 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 Nothing changed Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242965 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 God! Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO members ('username', 'password', 'email') VALUES ('$username', '$password', '$email')") or die(mysql_error()); //Close mysql mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242968 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 errrrrrrrrr!!! 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 ''username', 'password', 'email') VALUES ('ritchie', '64423c6f5ffd6a3205e0ad788ed' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242970 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 Try this: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = "INSERT INTO members ('username', 'password', 'email') VALUES ($username,$password,$email)"; echo $query; die(); mysql_query($query) or die(mysql_error()); //Close mysql mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242977 Share on other sites More sharing options...
john010117 Posted May 1, 2007 Share Posted May 1, 2007 //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("INSERT INTO `members` (username, password, email) VALUES ('$username', '$password', '$email')") or die(mysql_error()); //Close mysql mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242978 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 john010117, Thanks, but we've already tried that. But there is no harm in trying it again! Go for it ritchie! Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242980 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 I don't think we did cause that just worked. LADIES AND GENTLEMEN, we can finally mark this damn thread solved! You're both getting friendly donations when the site is up and running! Thank you guys so much especially you Bob for sticking wit me, lol Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242983 Share on other sites More sharing options...
RitchieGunz Posted May 1, 2007 Author Share Posted May 1, 2007 I can finally do the dishes, they've been sitting there since yesterday, lmao Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242985 Share on other sites More sharing options...
bobleny Posted May 1, 2007 Share Posted May 1, 2007 No, thank, john010117! He got it to work... I'm not real good with MySQL I must admit... I can usually solve my problems... Quote Link to comment https://forums.phpfreaks.com/topic/49229-solved-registrationadding-members-to-database/page/4/#findComment-242987 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.