prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $error = 'An account with this email already exists.'; } else { // Insert new user $password_hash = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)"); if ($stmt->execute([$name, $email, $password_hash])) { $success = 'Registration successful! You can now log in.'; } else { $error = 'Something went wrong. Please try again later.'; } } } catch (PDOException $e) { // In a real app, you would log this error. $error = 'Database error. Please try again later.'; // error_log($e->getMessage()); } } } ?>
Already have an account? Login here.