Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3.  
  4. $username = mysql_real_escape_string($_POST['username']);  
  5. $email = mysql_real_escape_string($_POST['email']);  
  6. $password = mysql_real_escape_string($_POST['password']);
  7.  
  8. //generate unique salt
  9. $salt = uniqid(mt_rand());
  10.  
  11. //combine email,pass,and salt together
  12. $combine = $email . $password . $salt;
  13.  
  14. //md5 hash the combined password
  15. $hash = md5($combine);
  16.  
  17.  //insert the values into the database  
  18.  $result = mysql_query("INSERT INTO users (username, password, email, salt) VALUES ('".$username."', '".$hash."', '".$email."', '".$salt."')") or die("MySQL Error: ".mysql_error());  
  19.  
  20.  //let the user know of success or failure  
  21.     if ($result) {  
  22.         echo '<h1>Success</h1>';  
  23.     } else {  
  24.         echo '<h1>Failure</h1>';  
  25.     }
  26. //registration for forums
  27. //Query to select the max number of users in the table
  28. $sql = "SELECT MAX(user_id) AS total FROM phpbb_users";
  29. //$row = mysql_fetch_array(mysql_query($sql));
  30. mysql_query($sql);
  31. //Taking the max number of records and adding 1 for the next user_id
  32. $user_id = total + 1;
  33.  
  34. //Query to insert the basics into the users table.
  35. //NOTE - Take validation into your own hands, this is just an example.
  36. $sql = "INSERT INTO phpbb_users (user_id, username, user_regdate,
  37. user_password, user_email,user_active)
  38. VALUES ($user_id, '$username',".time().",'$hash','$email','1')";
  39.  
  40. //Insert the user
  41. mysql_query($sql);
  42.  
  43. //Setup the users group so he/she has posting ability.
  44. //Why group_id=3?
  45. //On a basic PHPBB installation:
  46. // ID #1 = Visitor/Guest
  47. // ID #2 = Admin
  48. // ID #3 = Basic registered user
  49. //If you have a custom user group setup,
  50. //replace 3 with the id number.
  51.  
  52. $group_id=3;
  53.  
  54. $sql = "INSERT INTO phpbb_user_group (user_id,
  55. group_id, user_pending)
  56. VALUES ($user_id, $group_id, 0)";
  57.  
  58. //Insert user into the correct group.
  59. mysql_query($sql);
  60.  
  61.  
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement