Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config.php';
- $username = mysql_real_escape_string($_POST['username']);
- $email = mysql_real_escape_string($_POST['email']);
- $password = mysql_real_escape_string($_POST['password']);
- //generate unique salt
- $salt = uniqid(mt_rand());
- //combine email,pass,and salt together
- $combine = $email . $password . $salt;
- //md5 hash the combined password
- $hash = md5($combine);
- //insert the values into the database
- $result = mysql_query("INSERT INTO users (username, password, email, salt) VALUES ('".$username."', '".$hash."', '".$email."', '".$salt."')") or die("MySQL Error: ".mysql_error());
- //let the user know of success or failure
- if ($result) {
- echo '<h1>Success</h1>';
- } else {
- echo '<h1>Failure</h1>';
- }
- //registration for forums
- //Query to select the max number of users in the table
- $sql = "SELECT MAX(user_id) AS total FROM phpbb_users";
- //$row = mysql_fetch_array(mysql_query($sql));
- mysql_query($sql);
- //Taking the max number of records and adding 1 for the next user_id
- $user_id = total + 1;
- //Query to insert the basics into the users table.
- //NOTE - Take validation into your own hands, this is just an example.
- $sql = "INSERT INTO phpbb_users (user_id, username, user_regdate,
- user_password, user_email,user_active)
- VALUES ($user_id, '$username',".time().",'$hash','$email','1')";
- //Insert the user
- mysql_query($sql);
- //Setup the users group so he/she has posting ability.
- //Why group_id=3?
- //On a basic PHPBB installation:
- // ID #1 = Visitor/Guest
- // ID #2 = Admin
- // ID #3 = Basic registered user
- //If you have a custom user group setup,
- //replace 3 with the id number.
- $group_id=3;
- $sql = "INSERT INTO phpbb_user_group (user_id,
- group_id, user_pending)
- VALUES ($user_id, $group_id, 0)";
- //Insert user into the correct group.
- mysql_query($sql);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement