Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (empty($form_errors)) {
- $email = $_POST['email'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $invitationcode = $_POST['invitationcode'];
- $hashed_password = password_hash($password, PASSWORD_DEFAULT);
- try {
- $sqlInsert = "INSERT INTO users (username, email, password, invitationcode, joindate)
- VALUES (:username, :email, :password, :invitationcode, now())";
- $statement = $db->prepare($sqlInsert);
- $statement->execute(array(':username'=> $username, ':email' => $email, ':password' => $hashed_password, ':invitationcode' => $invitationcode));
- if ($statement->rowCount() == 1) {
- $result = "Registration successful!";
- }
- } catch (PDOException $error) {
- $result = "Registration failed: ".$error->getMessage()."";
- }
- } else {
- if (count($form_errors) == 1) {
- $result = "There was 1 error in the form!";
- foreach ($form_errors as $errorForm) {
- $result .= $errorForm;
- }
- } else {
- $result = "There were " .count($form_errors). "errors in the form";
- foreach ($form_errors as $errorForm) {
- $result .= $errorForm;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement