Advertisement
Guest User

AddRecord

a guest
Mar 4th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>ALL</title>
  5.  
  6. <meta charset="UTF-8">
  7.  
  8. <link href="styles/recordsStyle.css" type "text/css" rel="stylesheet" />
  9. </head>
  10.  
  11. <body>
  12. <h1>Records</h1>
  13.  
  14. <br />
  15.  
  16. <?php
  17.  
  18. $theFirstName = $_POST["first_name"];
  19. $theLastName = $_POST["last_name"];
  20. $theWhatTown = $_POST["what_town"];
  21. $theWhatCounty = $_POST["what_county"];
  22. $theWhatMobile = $_POST["what_mobile"];
  23. $theWhatEmail = $_POST["what_email"];
  24. $theContactBy = $_POST["contact_by"];
  25. $theNewsletterSubscription = $_POST["newsletter_subscription"];
  26. $theAnyComments = $_POST["any_comments"];
  27. $dsn = 'mysql:host=mysql02host.comp.dkit.ie;dbname=YOUR D NUMBER';
  28. $username = 'YOUR D NUMBER';
  29. $password = 'YOUR SQL PASSWORD';
  30.  
  31.  
  32. try {
  33. $db = new PDO($dsn, $username, $password);
  34. } catch (PDOException $e) {
  35. $error_message = $e->getMessage();
  36. echo "<h1>DATABASE PROBLEM: " . $error_message . ".</h1>";
  37. exit();
  38. }
  39.  
  40.  
  41. $query = 'INSERT INTO table_records (firstName, lastName, whatTown, whatCounty, whatMobile, whatEmail, contactBy, newsletterSubscription, anyComments) VALUES (:theFirstName, :theLastName, :theWhatTown, :theWhatCounty, :theWhatMobile, :theWhatEmail, :theContactBy, :theNewsletterSubscription, :theAnyComments)';
  42.  
  43. $statement = $db->prepare($query);
  44.  
  45. $statement->bindValue(":theFirstName", $theFirstName);
  46. $statement->bindValue(":theLastName", $theLastName);
  47. $statement->bindValue(":theWhatTown", $theWhatTown);
  48. $statement->bindValue(":theWhatCounty", $theWhatCounty);
  49. $statement->bindValue(":theWhatMobile", $theWhatMobile);
  50. $statement->bindValue(":theWhatEmail", $theWhatEmail);
  51. $statement->bindValue(":theContactBy", $theContactBy);
  52. $statement->bindValue(":theNewsletterSubscription", $theNewsletterSubscription);
  53. $statement->bindValue(":theAnyComments", $theAnyComments);
  54. $statement->execute();
  55. $statement->closeCursor()
  56. ?>
  57.  
  58. <table>
  59. <tr>
  60. <th>First Name</th>
  61. <th>Last Name</th>
  62. <th>Town</th>
  63. <th>County</th>
  64. <th>Mobile</th>
  65. <th>Email</th>
  66. <th>Contact By</th>
  67. <th>Newletter Subcription</th>
  68. <th>Any Comments/Questions</th>
  69. </tr>
  70.  
  71.  
  72. <tr>
  73.  
  74. <td><?php echo $theFirstName; ?></td>
  75. <td><?php echo $theLastName; ?></td>
  76. <td><?php echo $theWhatTown; ?></td>
  77. <td><?php echo $theWhatCounty; ?></td>
  78. <td><?php echo $theWhatMobile; ?></td>
  79. <td><?php echo $theWhatEmail; ?></td>
  80. <td><?php echo $theContactBy; ?></td>
  81. <td><?php echo $theNewsletterSubscription; ?></td>
  82. <td><?php echo $theAnyComments; ?></td>
  83. </tr>
  84. </table>
  85.  
  86. <br />
  87.  
  88. <input type="button" onclick="window.location.href = 'index.html'" value="Home" />
  89.  
  90.  
  91. <br />
  92. </body>
  93. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement