我是编程新手。目前,我开发了一个系统,注册部分。注册部分成功保存到数据库中。我想知道的是如何在注册成功后弹出一个带有一个按钮的警报对话框,例如“确定”并重定向到另一个页面,例如主页。现在我只回声“成功保存”下面是我当前的代码<?phprequire "DbConnect.php"; $name = $_POST['name']; $badgeid = $_POST['badgeid']; $position = $_POST['position']; $department = $_POST['department']; $factory = $_POST['factory']; $reviewer = $_POST['reviewer']; $title = $_POST['title']; $year = $_POST['year']; $month = $_POST['month']; $suggestionwill = $_POST['suggestionwill']; $present = $_POST['present']; $details = $_POST['details']; $benefit = $_POST['benefit'];$sql_query = "INSERT INTO topsuggest (name,badgeid,position,department,factory,reviewer,title,year,month,suggestionwill,present,details,benefit) VALUES('$name','$badgeid','$position','$department','$factory','$reviewer','$title','$year','$month','$suggestionwill','$present','$details','$benefit')";if(mysqli_query($conn,$sql_query)){echo "<p id='msg'></p>";}else{echo "Error!! Not Saved".mysqli_error($con);}?>
2 回答
梵蒂冈之花
TA贡献1900条经验 获得超5个赞
只需使用 php 标头并使用 javascript 来提醒消息。
if(mysqli_query($conn,$sql_query))
{
echo "<script>alert('Successfuly Saved');</script>";
header('Location: PATH TO BE REDIRECTED');
}
举个例子
if(mysqli_query($conn,$sql_query))
{
echo "<script>alert('Successfuly Saved');</script>";
header('Location: ../Insert/Index.php');
}
请注意 Location: 之间的空格是强制性的
- 2 回答
- 0 关注
- 104 浏览
添加回答
举报
0/150
提交
取消