prepare('SELECT * FROM registrations WHERE edit_token = ?'); $stmt->execute([$token]); $registration = $stmt->fetch(); if (!$registration) { $error = 'Invalid registration token.'; } } else { $error = 'No token provided.'; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && $registration) { $fullname = trim($_POST['fullname'] ?? ''); $email = trim($_POST['email'] ?? ''); $mobile_no = trim($_POST['mobile_no'] ?? ''); $job_description = trim($_POST['job_description'] ?? ''); if (empty($fullname) || empty($email) || empty($mobile_no)) { $error = 'Full Name, Email, and Mobile Number are required.'; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = 'Invalid email format.'; } else { try { $stmt = $pdo->prepare( 'UPDATE registrations SET fullname = ?, email = ?, mobile_no = ?, job_description = ? WHERE id = ?' ); $stmt->execute([$fullname, $email, $mobile_no, $job_description, $registration['id']]); $_SESSION['success_message'] = 'Registration updated successfully!'; header('Location: index.php'); exit; } catch (PDOException $e) { error_log($e->getMessage()); $error = 'An error occurred while updating.'; } } } ?>