Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. function userSignup($username, $email, $password) {
  2. require ("include/db_connect.php");
  3.  
  4.     $username = trim($_POST['username']);
  5.     $password = ($_POST['password']);
  6.        
  7.     $salt = uniqid($username);
  8.     $algo = "6";
  9.     $rounds = "5000";
  10.  
  11.     $crypt_salt = "$" . $algo . "$rounds=" . $rounds . "$" . $salt;
  12.     $hashed_pass = crypt($password, $crypt_salt);
  13.  
  14. /*** prepare the SQL statement ***/
  15. $stmt = $dbh->prepare("INSERT INTO Accounts (username, email, hashed_pw) VALUES (?, ?, ?)");
  16.    
  17. /*** bind the paramaters ***/
  18. $stmt->bindParam(1, $username, PDO::PARAM_STR);
  19. $stmt->bindParam(2, $email, PDO::PARAM_STR);
  20. $stmt->bindParam(3, $hashed_pass, PDO::PARAM_STR);
  21.  
  22. /*** execute the prepared statement ***/
  23. $stmt->execute();
  24.  
  25. /*** close the database connection ***/
  26. $dbh = null;   
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement