Files
portal_v3/portal/admin/services/v3/process-signup.php
equippedcoding-master 1c59875b8a initial commit 2
2025-09-17 15:19:57 -05:00

62 lines
1.4 KiB
PHP

<?php
require_once "../include.php";
// /home/cradle2careertxxyz/portal/dashboard/core/api/php/init.php
// if (empty($_POST["name"])) {
// die("Name is required");
// }
if ( ! filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
die("Valid email is required");
}
if (strlen($_POST["password"]) < 8) {
die("Password must be at least 8 characters");
}
if ( ! preg_match("/[a-z]/i", $_POST["password"])) {
die("Password must contain at least one letter");
}
if ( ! preg_match("/[0-9]/", $_POST["password"])) {
die("Password must contain at least one number");
}
if ($_POST["password"] !== $_POST["password_confirmation"]) {
die("Passwords must match");
}
$password_hash = password_hash($_POST["password"], PASSWORD_DEFAULT);
$mysqli = func_get_database();
$sql = "INSERT INTO " . $GLOBALS["AUTH_USER_TABLE"] . " (name, email, username, password_hash) VALUES (?, ?, ?, ?)";
$stmt = $mysqli->stmt_init();
if ( ! $stmt->prepare($sql)) {
die("SQL error: " . $mysqli->error);
}
$stmt->bind_param("ssss",
$_POST["name"],
$_POST["email"],
$_POST["username"],
$password_hash);
if ($stmt->execute()) {
header("Location: signup-success.html");
exit;
} else {
if ($mysqli->errno === 1062) {
die("email already taken");
} else {
die($mysqli->error . " " . $mysqli->errno);
}
}