Guest User

Untitled

a guest
Feb 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "pridedri_news";
  4. $password = "BBIT/7949/1/1630";
  5. $database = "pridedri_NEWSLETTER";
  6.  
  7. try {
  8. $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
  9.  
  10. // set the PDO error mode to exception
  11. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.  
  13. $sql = $conn->prepare("INSERT INTO subscribers (email) VALUES (:email)");
  14. $sql->bindParam(':email', $_POST["email"]);
  15.  
  16. // even exec() returnes true or false!!!!
  17. if($conn->exec($sql)) {
  18. echo "Request sent successfully";
  19. }
  20.  
  21. } catch(PDOException $e) {
  22. echo "Connection failed: " . $e->getMessage();
  23. }
  24.  
  25.  
  26. //$conn = null;
  27.  
  28. ?>
  29.  
  30. <Doctype! html>
  31. <body>
  32.  
  33. <a href="http://pridedrivetours.co.ke/">Back</>
  34. </body>
  35.  
  36. </html>
Add Comment
Please, Sign In to add comment