daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Oct 17th, 2017 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Signup Form -->
  2.         <form id="signup-form" name="emailform" method="post" action="send_post.php">
  3.             <input type="email" name="email" id="email" placeholder="Email Address" />
  4.             <input type="submit" value="Sign Up" />
  5.         </form>
  6. <script src="assets/js/main.js"></script>
  7.    
  8. <?php
  9.  // Fetching Values From URL
  10. $servername = "*****";
  11. $username = "*****";
  12. $password = "*****";
  13. $dbname = "email";
  14. $email = $_POST['email'];
  15.  
  16. //Create connection
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18.  
  19. // Check connection
  20. if ($conn->connect_error) {
  21.     die("Connection failed: " . $conn->connect_error);
  22. }
  23.  
  24. //Insert the data
  25.  
  26. mysqli_query($conn,"INSERT INTO email (email)
  27. VALUES ('$email')");
  28.  
  29.  
  30. $conn->close();
  31. ?>
  32.    
  33. //Submitting the form
  34.                             $('#signup-form').submit(function () {
  35.  
  36.                                 $.ajax({
  37.                                     type: "POST",
  38.                                     url: "send_post.php",
  39.                                     data: $("#signup-form"),
  40.                                     success: function () {
  41.                                         alert("success");
  42.                                     }
  43.                                 });
  44.                                 e.preventDefault();
  45.                                 return false;
  46.                             });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top