Guest User

Untitled

a guest
Oct 17th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  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. });
Add Comment
Please, Sign In to add comment