title: MySQL - how to encrypt password
body: <p>I am looking to know how I can edit my code in order to encrypt users passwords. At the moment the user fills in an HTML form which submits to <code>customerRegister.php</code> which goes through a series of validations before submitting the query.</p>
  
  <p>customerRegister.php</p>
  
  <pre><code>registerUser($_POST['firstName'], $_POST['lastName'], $_POST['username'], $_POST['houseNo'], $_POST['StreetName'], $_POST['town'], $_POST['postCode'], $_POST['emailAddress'], $_POST['phoneNumber'], $_POST['password'], $_POST['conPassword'],$_POST['carRegistration'],$_POST['carMake'],$_POST['carModel'],$_POST['carYear'],$_POST['carEngineSize'],$_POST['carFuel']);
  
   function registerUser($firstName, $lastName, $username, $houseNo, $streetName, $town, $postCode, $emailAddress, $phoneNumber, $password, $conPassword, $registration, $carMake, $carModel, $carYear, $carEngineSize, $carFuel) {
  
        $registerQuery = new UserLoginQueries();
  
  /********************************
  SERIES OF VALIDATIONS
  ********************************/
  
  $registerQuery-&gt;insertUser($firstName, $lastName, $username, $houseNo, $streetName, $town, $postCode, $emailAddress, $phoneNumber, $password);
  </code></pre>
  
  <p>Those details are then passed to userLoginQueries.php where the query is executed.</p>
  
  <p>userLoginQueries.php</p>
  
  <pre><code>  public function insertUser($custFirstName, $custLastName, $username, $houseNo, $streetName, $town, $postCode, $email, $number, $pass) {
      $sth = $this-&gt;conn-&gt;prepare("INSERT INTO `customer`(`CustFirstName`, `CustLastName`, `HouseNo`, `StreetName`, `Town`, `PostCode`, `EmailAddress`, `PhoneNumber`, `Username`, `Password`) VALUES (?,?,?,?,?,?,?,?,?,?)");
      $sth-&gt;bindValue (1, $custFirstName);
      $sth-&gt;bindValue (2, $custLastName);
      $sth-&gt;bindValue (3, $houseNo);
      $sth-&gt;bindValue (4, $streetName);
      $sth-&gt;bindValue (5, $town);
      $sth-&gt;bindValue (6, $postCode);
      $sth-&gt;bindValue (7, $email);
      $sth-&gt;bindValue (8, $number);
      $sth-&gt;bindValue (9, $username);
      $sth-&gt;bindValue (10, $pass);
      $sth-&gt;execute(); 
    }
  </code></pre>
  
  <p>When the user enters their login information the following query is ran:</p>
  
  <pre><code>  public function queryLogin($username, $password) {
      $sth = $this-&gt;conn-&gt;prepare("SELECT * FROM customer WHERE Username = ? AND Password = ? AND UserType = 'Customer'");
      $sth-&gt;bindValue (1, $username);
      $sth-&gt;bindValue (2, $password);
      $sth-&gt;execute();
      $count = $sth-&gt;rowCount();
      return $count;
      }
  </code></pre>
  
  <p>How can I modify my code so that the users password is encrypted?</p>