Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2.  
  3. // Edit or Replace this try/catch statement to work with the current PHT configuration
  4. include '../includes/db.inc.php';
  5.  
  6. // Modify the If statement so the try only runs if the First Name field has been submitted AND the honeypot field is empty ''
  7. if (isset($_POST['myfname'])) {
  8. $myFName = $_POST['myfname'];
  9. $myTour = $_POST['tour'];
  10. $myLName = $_POST['mylname'];
  11. $myEmail = $_POST['myemail'];
  12. // If the if statement is true, save each form field value as a variable. These variable values will be used in the thank you page.
  13.  
  14. // And run the try/catch to attempt to insert data in the database. Modify the INSERT statement to write all the form filed values (except the honeypot) to the database.
  15. try
  16. {
  17. $sql = 'INSERT INTO reservations SET
  18. tour = :tour,
  19. fname = :fname,
  20. lname = :lname,
  21. email = :email';
  22. $s = $pdo->prepare($sql);
  23. $s->bindValue(':tour', $myTour);
  24. $s->bindValue(':myfname', $myFName);
  25. $s->bindValue(':mylname', $myLName);
  26. $s->bindValue(':myemail', $myEmail);
  27. $s->execute();
  28. }
  29. catch (PDOException $e)
  30. {
  31. $error = 'Error adding submitted joke: ' . $e->getMessage();
  32. include '../includes/error.html.php';
  33. exit();
  34. }
  35. // load the thank you page after the INSERT runs
  36. include 'success.html.php';
  37. // Add an else to load the initial page if the initial (line 19) if statement is false
  38. } else {
  39. include 'reservations.html.php'; //Modify this to include the initial file for this folder
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement