prepare($sql); $stmt->execute([$email]); if ($stmt->fetch()) { $errors[] = "Email is already registered."; } } if (empty($password)) { $errors[] = "Password is required."; } elseif (strlen($password) < 8) { $errors[] = "Password must be at least 8 characters long."; } if ($password !== $password_confirm) { $errors[] = "Passwords do not match."; } if (empty($errors)) { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $sql = "INSERT INTO clients (name, email, password) VALUES (?, ?, ?)"; $stmt = db()->prepare($sql); if ($stmt->execute([$name, $email, $hashed_password])) { // $_SESSION['client_id'] = db()->lastInsertId(); // $_SESSION['client_name'] = $name; header("Location: login-client.php"); exit; } else { $errors[] = "Something went wrong. Please try again later."; } } } ?>