Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Signup Form -->
- <form id="signup-form" name="emailform" method="post" action="send_post.php">
- <input type="email" name="email" id="email" placeholder="Email Address" />
- <input type="submit" value="Sign Up" />
- </form>
- <script src="assets/js/main.js"></script>
- <?php
- // Fetching Values From URL
- $servername = "*****";
- $username = "*****";
- $password = "*****";
- $dbname = "email";
- $email = $_POST['email'];
- //Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //Insert the data
- mysqli_query($conn,"INSERT INTO email (email)
- VALUES ('$email')");
- $conn->close();
- ?>
- //Submitting the form
- $('#signup-form').submit(function () {
- $.ajax({
- type: "POST",
- url: "send_post.php",
- data: $("#signup-form"),
- success: function () {
- alert("success");
- }
- });
- e.preventDefault();
- return false;
- });
Add Comment
Please, Sign In to add comment