Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. if (empty($form_errors)) {
  2. $email = $_POST['email'];
  3. $username = $_POST['username'];
  4. $password = $_POST['password'];
  5. $invitationcode = $_POST['invitationcode'];
  6.  
  7. $hashed_password = password_hash($password, PASSWORD_DEFAULT);
  8.  
  9. try {
  10. $sqlInsert = "INSERT INTO users (username, email, password, invitationcode, joindate)
  11. VALUES (:username, :email, :password, :invitationcode, now())";
  12.  
  13. $statement = $db->prepare($sqlInsert);
  14. $statement->execute(array(':username'=> $username, ':email' => $email, ':password' => $hashed_password, ':invitationcode' => $invitationcode));
  15.  
  16. if ($statement->rowCount() == 1) {
  17. $result = "Registration successful!";
  18. }
  19. } catch (PDOException $error) {
  20. $result = "Registration failed: ".$error->getMessage()."";
  21. }
  22. } else {
  23. if (count($form_errors) == 1) {
  24. $result = "There was 1 error in the form!";
  25.  
  26. foreach ($form_errors as $errorForm) {
  27. $result .= $errorForm;
  28. }
  29. } else {
  30. $result = "There were " .count($form_errors). "errors in the form";
  31.  
  32. foreach ($form_errors as $errorForm) {
  33. $result .= $errorForm;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement