Skip to content

Commit

Permalink
fix(register) create user in db
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmrval committed Jun 12, 2024
1 parent ab210c9 commit 7530c24
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/register/main.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php


if ($_SERVER['REQUEST_METHOD'] == 'POST') {

if ($_POST['password'] !== $_POST['confirmPassword']) {
Expand All @@ -13,6 +14,18 @@
if ($user) {
$errorMessage = "Email already used.";
}

if (!isset($errorMessage)) {
$query = $conn->prepare("INSERT INTO users (firstName, lastName, email, password) VALUES (:firstName, :lastName, :email, :password)");
$query->bindParam(':firstName', $_POST['firstName']);
$query->bindParam(':lastName', $_POST['lastName']);
$query->bindParam(':email', $_POST['email']);
$query->bindParam(':password', password_hash($_POST['password'], PASSWORD_DEFAULT));
$query->execute();

header("Location: login.php");
exit();
}
}

}
Expand Down

0 comments on commit 7530c24

Please sign in to comment.