你能同时拥有两个“死”功能吗?

时间:2015-03-04 19:17:01

标签: php

我正在创建一个网站,供人们评论他们所处理的公司。当Web用户输入他的注释并提交时,这些注释将存储在数据库中。然后他将被问到两个问题之一:他是否想对另一家公司发表另一条评论,或者他是否想要退出。您将在下面看到" die"函数,用户可以选择进行另一个评论。但我的问题是,我该怎样做另一个" die"将他记录下来的陈述?注销页面名为" logout.php"。 "死"将他记录下来的陈述将是:

死了("我现在要退出"                  。 " 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'> &rarr; 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>

1 个答案:

答案 0 :(得分:1)

这不是你应该如何使用die。其重点是停止进一步执行脚本

请考虑使用echo

相关问题