Advertisement
Guest User

Untitled

a guest
Apr 8th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $dbusername = "";
  4. $dbpassword = "";
  5. $dbname = "";
  6.  
  7. $first_name = $_POST ['first_name'];
  8. $last_name = $_POST ['last_name'];
  9. $email = $_POST ['email'];
  10. $optin = $_POST ['optin'];
  11.  
  12. $conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
  13.  
  14. if ($conn->connect_error){
  15. die("Connection Error: " . $conn->connect_error);
  16. }
  17.  
  18. if (empty($first_name)) {
  19. echo "First name cannot be left blank";
  20. die();
  21. }
  22.  
  23. if (empty($last_name)) {
  24. echo "Last name cannot be left blank";
  25. die();
  26. }
  27.  
  28. if (empty($email)) {
  29. echo "Email cannot be left blank";
  30. die();
  31. }
  32.  
  33. $captcha = check_input($_POST['captcha']);
  34.  
  35. if (!captcha ==("/5/", $captcha))
  36. {
  37. echo ("Wrong Answer");
  38. }
  39.  
  40.  
  41. $data = "INSERT INTO registration (first_name, last_name, email, optin)
  42. VALUES ('$first_name', '$last_name', '$email', '$optin')";
  43.  
  44. if ($conn->query($data) === TRUE) {
  45. echo readfile("thanks.html");
  46. }
  47. else {
  48. echo "Connection Error: " . $data . "<br>" . $conn->error;
  49. }
  50.  
  51. $conn->close();
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement