我正在创建一个网站,人们可以在这里评论他们与之打过交道的公司。当网络用户输入他的评论并提交时,这些评论将存储在数据库中。然后,他将被问到两个问题之一:他想对另一家公司发表另一条评论吗?还是想注销。您将在下面的"die"函数旁边看到,用户可以选择发表另一条评论。但我的问题是,我如何做出另一个"死亡"声明,让他退出?注销页面被称为"logout.php"。将他注销的"die"语句类似于:
die("我现在想注销"."a href='logout.php'→请让我注销!/a");
(我忽略HTML标签。)
我的问题是,当我把"die"函数放在第一个"die"函数的正下方时(这样用户就可以看到两个超链接,一个是他想发表另一条评论,另一个是如果他只是想注销),我只能看到第一个超链接:-->发表另一个评论。我看不到允许用户注销的超链接。我不明白。有人能帮忙吗?
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:green}
h1 {color:blue}
/* Plenty of CSS goes in here */
</style>
</head>
<body>
<?php
require_once 'connect.php';
include "display.php";
// plenty of isset functions go in here
else if(isset($_POST['company']))
{
$company = $_POST['company'];
$username = $username;
$commentary = $_POST['commentary'];
// write comment to data base
mysqli_query($dbcon,"INSERT INTO `mycomments` (`username`,
`company`, `commentary`) VALUES ('$username',
'$company', '$commentary')");
mysqli_close($dbcon);
die("Your comments will be seen by: $company </br>"
. "<a href = 'recordedcomments.php'> → Make another
comment!</a>");
}
else {
?>
<h1>Which other company do you want to make a comment about?</h1>
<div id="form">
<form method="post" action="somefilename.php">
<!--Plenty of HTML goes in here-->
</form>
</div>
<script type='text/javascript'....></script>
</body>
</html>
这确实不是使用die
的方式。它的全部意义在于它停止了脚本的进一步执行。
请考虑改用echo
。