I have a newsletter sign up in a bootstrap modal.
What I am trying to achieve is when a client submits their email, it should give a success message in the modal directly underneath, on the same page without redirecting to a new page.
I am new to AJAX so just some direction would be helpful.
Here is my HTML code
<form form id="form1" name="form1" method="post" action="process.php">
<div class="input-group">
<input class="btn btn-lg" name="email" id="email" type="email" placeholder="Your Email" required/>
<button type="submit" class="button">Submit</button>
</div>
</form>
And below is process.php
/* Database config */
$db_host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_database = 'maxipakdb';
/* End config */
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
}
$email = $_POST['email'];
// Perform queries
mysqli_query(
$mysqli,
"INSERT INTO maxipaktable (id,email) VALUES (NULL,'$email')"
);
echo $email;