I've been wanting to post a javascript alert (a pop up window w/ a message) to simply say "Thanks! You've been added!". Once a user has entered in the details in the form and clicks the submit button.
I have googled how to do this, however when adding it, it never worked and have tried different ways but am getting stumped on how to do it now. If anyone knows what I am doing wrong then any help would be much appreciated.
I would also like to note this in a separate php file.
Below you will find my code;
insert.php
<?php
$con=mysqli_connect("localhost","cl51-main-3i6","password","cl51-main-3i6");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$firstname = mysqli_real_escape_string($con, $_POST['firstname']);
$lastname = mysqli_real_escape_string($con, $_POST['lastname']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$sql="INSERT INTO emails ( Firstname, Lastname, Email) VALUES ( '$firstname', '$lastname', '$email')";
if (!mysqli_query($con,$sql)) {
die('Error : ' . mysql_error($con));
}
echo '<script language="javascript">';
echo 'alert("Thank you! You've now joined the e-mail club!")';
echo '</script>';
header("Location: http://isometricstudios.co.uk/news.html");
exit;
mysqli_close($con);
?>
header()after sending html content out to the page. if you are doing this what I would recommend is forwarding them to the success page with a$_GETvalue stating successheader("Location: http://isometricstudios.co.uk?success=true"), then on the landing page,if($_GET['success'] == 'true')put your alert code