Create an Account
Already have an account? Login here
prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $error = 'Username already taken.'; } else { // Hash the password $hashed_password = password_hash($password, PASSWORD_DEFAULT); // Insert new user $insertStmt = $pdo->prepare("INSERT INTO users (username, password, role) VALUES (?, ?, ?)"); if ($insertStmt->execute([$username, $hashed_password, $role])) { $success = 'Registration successful! You can now login.'; } else { $error = 'Something went wrong. Please try again later.'; } } } catch (PDOException $e) { $error = 'Database error. Please try again later.'; } } } ?>
Already have an account? Login here