prepare("SELECT COUNT(*) FROM members WHERE LOWER(email) = LOWER(:email)");
$stmt->execute([
"email" => $data["email"],
]);
if ($stmt->fetch(PDO::FETCH_COLUMN) > 0) {
$errors["email"] = "That email address is already in use.";
}
$stmt = $db["data"]->prepare("SELECT COUNT(*) FROM members WHERE LOWER(handle) = LOWER(:handle)");
$stmt->execute([
"handle" => $data["handle"],
]);
if ($stmt->fetch(PDO::FETCH_COLUMN) > 0) {
$errors["handle"] = "That handle is taken.";
}
if (!isset($data['terms-privacy'])) {
$errors["terms-privacy"] = "Please agree to the terms.";
}
if (preg_match('/[^A-Za-z0-9-_]/', $_POST['handle'])) {
$errors["handle"] = "Please only use allowed characters.";
}
return $errors;
}
$description = "Sign up to submit your work to Sixfold.";
$title = "Sign Up";
if ($_SERVER["REQUEST_METHOD"] === "POST"):
$errors = validate_fields($_POST);
if (count($errors) === 0) {
$stmt = $db["data"]
->prepare('INSERT INTO members (name, handle, email, password, account_type, created_at, last_access)
VALUES (:name, :handle, :email, :password, :account_type, :created_at, :last_access)
RETURNING id');
$stmt->execute([
"name" => $_POST["name"],
"handle" => $_POST["handle"],
"email" => $_POST["email"],
"password" => password_hash($_POST['password'], PASSWORD_ARGON2ID),
"account_type" => 1,
"created_at" => date("Y-m-dTH:i:s"),
"last_access" => date("Y-m-dTH:i:s"),
]);
$stmt = $db['data']->query('SELECT * FROM members WHERE LOWER(email) = LOWER(:email)');
$stmt->execute([
'email' => $_POST['email'],
]);
$_SESSION['account'] = $stmt->fetch(PDO::FETCH_OBJ);
} else {
http_response_code(400);
}
endif;
if (isset($_SESSION["account"])) {
http_response_code(303);
header("Location: /");
die();
}
include "partials/head.php";
?>
= $title ?>
Your browser is not set to accept cookies. You cannot login or use certain portions of the site unless your browser accepts cookies. Please change your browser settings to accept cookies and try again. Thanks.
We encounterred an issue when processing your request; please try again.