Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = 'localhost';
- $user = 'root';
- $pass = 'root';
- $name = 'test';
- $mysqli = new mysqli($host, $user, $pass, $name);
- // The hashed password from the form
- $password = $_POST['p'];
- // Form data
- $firstname = $_POST['firstname'];
- $surname = $_POST['surname'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $password2 = $_POST['password2'];
- $day = $_POST['day'];
- $month = $_POST['month'];
- $year = $_POST['year'];
- $gender = $_POST['gender'];
- // Create a random salt
- $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
- // Create salted password (Careful not to over season)
- $password = hash('sha512', $password.$random_salt);
- // Add your insert to database script here.
- // Make sure you use prepared statements!
- if ($insert_stmt = $mysqli->prepare("INSERT INTO members (firstname, surname, email, password, salt, day, month, year, gender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
- $insert_stmt->bind_param('sssssssss', $firstname, $surname, $email, $password, $random_salt, $day, $month, $year, $gender);
- // Execute the prepared query.
- $insert_stmt->execute();
- }
- ?>
Add Comment
Please, Sign In to add comment