Jump to content

RitchieGunz

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by RitchieGunz

  1. I made that one modification with the preg_match and thats it. I put !$ in the all the fields and it does the same thing.
  2. This is gonna be really useful thread for people LOL I was getting this error also, but I fixed it by putting the dash at the end and it works. It probably thought it was range between those characters, dont see why. if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email'])) Warning: preg_match() [<function.preg-match>]: Compilation failed: range out of order in character class at offset 13 but its still just redirecting back to signup.php
  3. LOL well, Im really serious about learning this language and putting that site together. Im not gonna stop till its done. OK .. I enter fake info on the form .. it brings me to check.php but redirects me back to signup.php .. Im sure thats a good thing .. But I'm not seeing "You're username was too short" or "passwords didnt match" which I know I should be seeing.
  4. Im starting to catch on little by little .. There were a bunch of { that shoulda been } OK .. So I got the errors outta the way .. after entering some information and mismatchin passwords in the signup.php, it brings me to check.php but its blank. The name of my database is main and I have the table members in there with 4 fields (username, password, email, id) .. Let me know if anything is wrong in the code about that. Thanks. This is how my code looks now: <?php //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //If something went wrong, send them back to fix their mistakes if ($pass == FALSE) { //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>'; } ?>
  5. This is the whole code: (password is actually blank cause im running locally) <?php //Database Information //Username? $database_username = "root"; //Your password? $database_password = ""; //The name of the database you are trying to connect to $database_database = "members"; //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 = FALSE; { //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 = FALSE; { //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 = FALSE; { //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //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 = FALSE; } //If something went wrong, send them back to fix their mistakes if ($pass == FALSE) { //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>'; } ?>
  6. Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\xampp\site\check.php on line 161 That line is blank. And its after the ?> Am I not closing a funtion? This is the last chunk of lines: //Insert new user $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query ("INSERT INTO `users` (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>'; } ?>
  7. I was fixing codes fine, I tried googling this with no help: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampplite\htdocs\xampp\site\check.php on line 141 (The 3rd line is line 141) //Insert new user $query = mysql_query("INSERT INTO users ('username', 'password', 'email') VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error());
  8. Thanks, that fixed it. Now I gotta go thru all the lines lol.
  9. Yea, its already there .. Theres supposedly a problem on the check.php line
  10. Now I get this: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampplite\htdocs\xampp\site\signup.php on line 8 I've tried removing characters and testing and it still wont work. <html> <head> <title>Sign Up</title> </head> <body> <?php echo "<form action=/"check.php/" method=/"post/">"; if ($_SESSION['short_username'] == TRUE)
  11. WOW that solved it lol .. And I was 2 seconds away from reinstalling xampp Thank you so much
  12. Something is definitely wrong because I just get a blank page :'(
  13. Thanks alot man. Im suprised you've stayed with me so far and been so helpful But still, there remains a problem. I did all that exactly, changed username to root and left the password blank since its running locally. Problem is, when I view signup.php .. It just shows me some of the php code with a couple field boxes. I would really like to know whats causing this.
  14. Can you just give me a little step-by-step and fill in what I filled in wrong?, lol If possible, just give me exactly what I need so I can copy and paste it. Along with signup.php and check.php, should I have any other files in my root directory?
  15. Im pretty sure I slaughtered this, sorry for being a bother, lol This is what I got in signup.php ... When I add that stuff from Reply #23, It shows up when I view signup.php so I put it in check.php This is signup.php: <html> <head> <title>Sign Up</title> </head> <body> <form action="check.php" method="post"> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> Verify Password: <input type="password" name="varpassword" /><br /> E-mail: <input type="text" name="email" /><br /> <input type="submit" value="Sign Up" /> </form> </body> </html> And this is in check.php .. I did what you told me to in the comments, but I probably messed that up. <?php echo "<form action=/"check.php/" method=/"post/">" if ($_SESSION['short_username'] == TRUE) { echo "Your username was too short!<br />"; $_SESSION['short_username'] = FALSE; } if ($_SESSION['bad_username'] == TRUE) { echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_)<br />"; $_SESSION['bad_username'] = FALSE; } echo "Username: <input type=/"text/" name=/"username/" /><br />" if ($_SESSION['short_password'] == TRUE) { echo "Your password was too short!<br />"; $_SESSION['short_password'] = FALSE; } if ($_SESSION['bad_password'] == TRUE) { echo "Passwords may only contain alphanumeric characters<br />"; $_SESSION['bad_password'] = FALSE; } echo "Password: <input type=/"password/" name=/"password/" /><br /> if ($_SESSION['match_password'] == TRUE) { echo "Your passwords did not match!<br />"; $_SESSION['match_password'] = FALSE; } echo "Verify Password: <input type=/"password/" name=/"varpassword/" /><br />" if ($_SESSION['bad_email'] == TRUE) { echo "You have entered an invalid E-mail address<br />"; $_SESSION['bad_email'] = FALSE; } echo "E-mail: <input type=/"text/" name=/"email/" /><br />" <input type=/"submit/" value=/"Sign Up/" /> </form> if (strlen($_POST['username']) < 4) { if (strlen($_POST['password']) < 6) { if (strlen($_POST['email']) < { //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; $_SESSION['short_password'] = TRUE; $_SESSION['bad_email'] = TRUE; $_SESSION['match_password'] = TRUE; //Tell the script that something went wrong $pass = FALSE; { //Do that for all the fields. //You should change the "4" to an "8" for the email address. //No email address will have less than 8 characters! if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { if (preg_match("/[^a-zA-Z0-9]/", $_POST['password'])) { if (preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email'])) { //There 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; $_SESSION['bad_password'] = TRUE; $_SESSION['match_password'] = TRUE; $_SESSION['bad_email'] = TRUE; //Tell the script that something went wrong $pass = FALSE; } //Again, do that for all the fields. //You should use preg_match("/[^a-zA-Z0-9]/", $_POST['password']) for the password. //You should use preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']) for the email! //I do this part to make sure they don't do anything stupid. //Like if they put "2+2" for the password and "4" for the varpassword, //Then this would stop that from proving true! $password = md5($_POST['password']); $varpassword = md5($_POST['varpassword']); if ($password != $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 = FALSE; } if ($pass == FALSE) { //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 { //Hey they past our test! //Looking at all this, I don't know how! lol //You can now change their password into something unreadable. //I do it again to make sure nothing happened to it on the way... $password = md5($_POST['password']); //Now that you have all their info, you can 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 $query = mysql_query("INSERT INTO users ('username', 'password', 'email') VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error()); //Close mysql mysql_close(); //Now they have an account! } ?>
  16. Nope, Im just using wordpad. So all that goes into signup.php? Then whats supposed to go into check.php?
  17. Ok, I found the directory. Sorry about all the questions, just better to ask since Im on a slow computer. Problem Now. I've made signup.html and thats working fine. What exactly should I be putting in check.php? Because this is what I get when I press the signup button: if ($_SESSION['short_username'] == TRUE) { echo "Your username was too short! "; } if ($_SESSION['bad_username'] == TRUE) { echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_) "; } Username: if ($_SESSION['short_password'] == TRUE) { echo "Your password was too short! "; } if ($_SESSION['bad_password'] == TRUE) { echo "Passwords may only contain alphanumeric characters "; } Password: if ($_SESSION['match_password'] == TRUE) { echo "Your passwords did not match! "; } Verify Password: if ($_SESSION['bad_email'] == TRUE) { echo "You have entered an invalid E-mail address "; } E-mail: ?> And just incase I've done anything wrong, this is what I got in signup.html: <html> <body> <form action="check.php" method="post"> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> Verify Password: <input type="password" name="varpassword" /><br /> E-mail: <input type="text" name="email" /><br /> <input type="submit" value="Sign Up" /> </form> <?php 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 = FALSE; { //Do that for all the fields. //You should change the "4" to an "8" for the email address. //No email address will have less than 8 characters! if (preg_match("/[^a-zA-Z0-9_-]/", $_POST['username'])) { //There 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 = FALSE; } //Again, do that for all the fields. //You should use preg_match("/[^a-zA-Z0-9]/", $_POST['password']) for the password. //You should use preg_match("/[^a-zA-Z0-9_-.@]/", $_POST['email']) for the email! //I do this part to make sure they don't do anything stupid. //Like if they put "2+2" for the password and "4" for the varpassword, //Then this would stop that from proving true! $password = md5($_POST['password']); $varpassword = md5($_POST['varpassword']); if ($password != $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 = FALSE; } if ($pass == FALSE) { //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 //I like to kill the script at this point. die(); } else { //Hey they past our test! //Looking at all this, I don't know how! lol //You can now change their password into something unreadable. //I do it again to make sure nothing happened to it on the way... $password = md5($_POST['password']); //Now that you have all their info, you can 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 $query = mysql_query("INSERT INTO users ('username', 'password', 'email') VALUES ($_POST['username'], $password, $_POST['email'])") or die(mysql_error()); //Close mysql mysql_close(); //Now they have an account! } ?> </body> </html> And this is in check.php, Which I know is probably wrong, lol <html> <body> <?php <form action="check.php" method="post"> if ($_SESSION['short_username'] == TRUE) { echo "Your username was too short!<br />"; } if ($_SESSION['bad_username'] == TRUE) { echo "Usernames may only contain alphanumeric characters, dashes (-) and underscores (_)<br />"; } Username: <input type="text" name="username" /><br /> if ($_SESSION['short_password'] == TRUE) { echo "Your password was too short!<br />"; } if ($_SESSION['bad_password'] == TRUE) { echo "Passwords may only contain alphanumeric characters<br />"; } Password: <input type="password" name="password" /><br /> if ($_SESSION['match_password'] == TRUE) { echo "Your passwords did not match!<br />"; } Verify Password: <input type="password" name="varpassword" /><br /> if ($_SESSION['bad_email'] == TRUE) { echo "You have entered an invalid E-mail address<br />"; } E-mail: <input type="text" name="email" /><br /> <input type="submit" value="Sign Up" /> </form> ?> </body> </html>
  18. I can hit the localhost, I just don't know where that specific directory is
  19. I went to xampp/htdocs and tried viewing the index file. This is what I got: <?php if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/xampp/'); exit; ?> Something is wrong with the XAMPP Lite installation :-( And when I view it in firefox, I just get: "Something is wrong with the XAMPP Lite installation :-(" Do I gotta edit httpd.conf ?? What could be wrong?
  20. Also, where should I be placing these files to view them? Once I can get all setup and start editing, I'll be good to go I love tweaking scripts to make them just right and I love the feeling that I've done it mostly myself, but I still can't even get to that point. lol.
  21. So I've created the database called "members" .. I put in username, password, email and id tables in. I made the id primary and set it to auto-increment. Now how do I go about actually viewing and editing php files? I tried looking at one through internet explorer but it just came up blank
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.