Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. $dsn = 'mysql:host=localhost;dbname=dbname';
  3. $username = 'username';
  4. $password = 'password';
  5. $hashOptions = [
  6. 'cost' => 10,
  7. ];
  8.  
  9. $email = $_GET['email'];
  10. $userlogin = $_GET['username'];
  11. $userpass = $_GET['password'];
  12. $hash = $_GET['hash'];
  13.  
  14. $secretKey = 'secretkey';
  15.  
  16. $createdHash = md5($email . $userlogin . $userpass . $secretKey);
  17.  
  18. if ($createdHash == $hash)
  19. {
  20. try
  21. {
  22. $dbh = new PDO($dsn, $username, $password);
  23. $hashedpass = password_hash($userpass, PASSWORD_DEFAULT, $hashOptions);
  24.  
  25. $statement = $dbh->prepare ("INSERT INTO users (username, password, creationdate, email) values (:username, :hashedpass, NOW(), :email);");
  26. $statement->bindParam(':username', $userlogin);
  27. $statement->bindParam(':hashedpass', $hashedpass);
  28. $statement->bindParam(':email', $email);
  29.  
  30. $statement->execute();
  31. }
  32. catch (PDOException $e)
  33. {
  34. echo "Error: " . $e->getMessage() . "<br/>";
  35. die ();
  36. }
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement