Advertisement
lowheartrate

Password hashing

Jun 1st, 2015
351
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.             } else {
  3.                 $servername = "198.71.225.55:3306";
  4.                 $dbuser = "";
  5.                 $dbpw = "";
  6.                 $dbname = "heartfx_users";
  7.                 $db = new PDO( 'mysql:host=198.71.225.55:3306;dbname=heartfx_users', $dbuser, $dbpw );
  8.  
  9.                 $form = $_POST;
  10.                 $firstname = $form['firstname'];
  11.                 $lastname = $form['lastname'];
  12.                 $username = $form['username'];
  13.                 $password = $form['password'];
  14.                 $email = $form['email'];
  15.  
  16.                 // Hash a new password for storing in the database.
  17.                 $password = password_hash($password, PASSWORD_BCRYPT);
  18.  
  19.  
  20.                 $sql = "INSERT INTO Users ( firstname, lastname, username, password, email )
  21.                 VALUES ( :firstname, :lastname, :username, :password, :email )";
  22.  
  23.                 $query = $db->prepare( $sql );
  24.                 $result = $query->execute( array( ':firstname'=>$firstname, ':lastname'=>$lastname, ':username'=>$username, ':password'=>$password, ':email'=>$email ) );
  25.             }
  26.         ?>
Advertisement
RAW Paste Data Copied
Advertisement