hi there im a little new to all of this so please bear with me.
I am trying to have a form that registers first, last, email into a table. if the email already exists id like to divert to a page and update the timestamp in the record for that email address. im not sure where to start. thanks in advance
edit: to clarify the goal here is
1.person A enters their details, if there is no record of their email address then a new record is created, timestamped and they proceed to the next page
- person B enters their details, they have registered before, the database updates their records timestamp and they proceed to the next page
// Attempt insert query execution
try{
// Create prepared statement
$sql = "INSERT INTO sessions (first, last, email) VALUES (:first, :last, :email)";
$stmt = $pdo->prepare($sql);
// Bind parameters to statement
$stmt->bindParam(':first', $_REQUEST['first']);
$stmt->bindParam(':last', $_REQUEST['last']);
$stmt->bindParam(':email', $_REQUEST['email']);
// Execute the prepared statement
$stmt->execute();
header('Location: stream.php');
} catch(PDOException $e){
die("ERROR: Could not able to execute $sql. " . $e->getMessage());
}
// Close connection
unset($pdo);