当提交表单并在mysql中插入记录时,如何在页面顶部显示一条消息是我的action.php页面。
<?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);
}
?>
然后在index.php
<?php
if ($_GET['subscribe'] =='yes'){
echo 'You succesully subscribe to our exclusive promos';
}
?>
答案 0 :(得分:0)
您可以使用第index.php
页中的JavaScript提醒框来实现此目的。
<?php
if ($_GET['subscribe'] =='yes'){
echo '<script language="javascript">';
echo 'alert("Form has been submitted")';
echo '</script>';
}
?>
希望它有所帮助。