Reputation: 153
How to make a message appear in the top of the page when a form has been submitted and a record has been inserted in mysql below is my action.php page.
<?php $email =$_POST["email"];
include "includes/db_config.php";
$sql = "INSERT INTO subscribers(email)
VALUES('$email')";
if (mysqli_query($conn, $sql)) {
header('location:index.php?subscribe=yes');
} else {
echo "Failed" . $sql . "<br>" . mysqli_error($conn);
}
?>
and then at index.php
<?php
if ($_GET['subscribe'] =='yes'){
echo 'You succesully subscribe to our exclusive promos';
}
?>
Upvotes: 0
Views: 602
Reputation: 1233
You can use JavaScript alert box in page index.php
for this purpose.
<?php
if ($_GET['subscribe'] =='yes'){
echo '<script language="javascript">';
echo 'alert("Form has been submitted")';
echo '</script>';
}
?>
Hope it helps.
Upvotes: 1