Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dsn = 'mysql:host=localhost;dbname=dbname';
- $username = 'username';
- $password = 'password';
- $hashOptions = [
- 'cost' => 10,
- ];
- $email = $_GET['email'];
- $userlogin = $_GET['username'];
- $userpass = $_GET['password'];
- $hash = $_GET['hash'];
- $secretKey = 'secretkey';
- $createdHash = md5($email . $userlogin . $userpass . $secretKey);
- if ($createdHash == $hash)
- {
- try
- {
- $dbh = new PDO($dsn, $username, $password);
- $hashedpass = password_hash($userpass, PASSWORD_DEFAULT, $hashOptions);
- $statement = $dbh->prepare ("INSERT INTO users (username, password, creationdate, email) values (:username, :hashedpass, NOW(), :email);");
- $statement->bindParam(':username', $userlogin);
- $statement->bindParam(':hashedpass', $hashedpass);
- $statement->bindParam(':email', $email);
- $statement->execute();
- }
- catch (PDOException $e)
- {
- echo "Error: " . $e->getMessage() . "<br/>";
- die ();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement