Guest User

Untitled

a guest
Sep 26th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $user = 'root';
  5. $pass = 'root';
  6. $name = 'test';
  7. $mysqli = new mysqli($host, $user, $pass, $name);
  8.        
  9.        
  10. // The hashed password from the form
  11. $password = $_POST['p'];
  12. // Form data
  13. $firstname = $_POST['firstname'];
  14. $surname = $_POST['surname'];
  15. $email = $_POST['email'];
  16. $password = $_POST['password'];
  17. $password2 = $_POST['password2'];
  18. $day = $_POST['day'];
  19. $month = $_POST['month'];
  20. $year = $_POST['year'];
  21. $gender = $_POST['gender'];
  22.  
  23. // Create a random salt
  24. $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
  25. // Create salted password (Careful not to over season)
  26. $password = hash('sha512', $password.$random_salt);
  27.  
  28. // Add your insert to database script here.
  29. // Make sure you use prepared statements!
  30. if ($insert_stmt = $mysqli->prepare("INSERT INTO members (firstname, surname, email, password, salt, day, month, year, gender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
  31. $insert_stmt->bind_param('sssssssss', $firstname, $surname, $email, $password, $random_salt, $day, $month, $year, $gender);
  32. // Execute the prepared query.
  33. $insert_stmt->execute();
  34. }
  35. ?>
Add Comment
Please, Sign In to add comment