Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. if ($_POST[register]) {
  2. // the above line checks to see if the html form has been submitted
  3. $username = $_POST[username];
  4. $password = $_POST[pass];
  5. $cpassword = $_POST[cpass];
  6. $email = $_POST[email];
  7. //the above lines set variables with the user submitted information
  8. if($username==NULL||$password==NULL||$cpassword==NULL||$email==NULL||$paypal==NULL||$country==NULL) {
  9. //checks to make sure no fields were left blank
  10. $notice = "A field was left blank.";
  11. }else{
  12. //none were left blank! We continue...
  13. if($password != $cpassword) {
  14. // the passwords are not the same!
  15. $notice = "Passwords do not match";
  16. }else{
  17. // the passwords are the same! we continue...
  18. //$password = md5($password);
  19. $password = password_hash("$password", PASSWORD_DEFAULT);
  20. // encrypts the password
  21. $checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
  22. $checkname= mysql_num_rows($checkname);
  23. $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
  24. $checkemail = mysql_num_rows($checkemail);
  25. if ($checkemail>0|$checkname>0) {
  26. // oops...someone has already registered with that username or email!
  27. $notice = "The username or email is already in use";
  28. }else{
  29. // noone is using that email or username! We continue...
  30. $query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
  31. // inserts the information into the database.
  32.  
  33. $lasterror = error_get_last(); $lasterror = $lasterror['message']." on line ".$lasterror['line'];
  34. $danewuserid = mysql_insert_id();
  35.  
  36. //conversions
  37. echo "
  38.  
  39. ";
  40.  
  41. if ($query === true) { $notice = "You have successfully registered! Now you can login."; }
  42. else { $notice = "An error occured when signing up. $lasterror Use the email form to report this."; }
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement