页面正在重定向而不运行进程


Page is redirecting without running the processes

此页面在没有运行验证过程的情况下进行重定向,如果我注释掉标头重定向,则所有进程都会正常工作,当页面加载时,只要我取消注释标头标记,它就会自动重定向,此页面是根据我创建的成员注册页面建模的,该页面运行良好,没有此问题,所以我看不到问题,请有人好心帮我解决这个问题好吗。

以下是标题标签注释掉的页面代码

 <?php
 include_once 'functions.php';
    //Start session
    sec_session_start();
    //Check whether the session variable SESS_MEMBER_ID is present or not
    if(!isset($_SESSION['sess_user_id']) || (trim($_SESSION['sess_user_id']) == '')) {
    header("location: login.php");
    exit();
    }
    if(!isset($_SESSION['login']) == '1') {
        header("location: admin_login.php");
        exit();
    }
    ?>
    <?php
    //display users info with checkbox to delete  
$sql = "SELECT * FROM `links` LIMIT 0, 30 ";  
$result = mysqli_query($mysqli, $sql);
?>
     <?php

// define variables and set to empty values
$link_titleErr = $type_of_linkErr = $web_linkErr = "";
$link_title = $type_of_link = $web_link = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $link_title = test_input($_POST["link_title"]);
  $type_of_link = test_input($_POST["select"]);
  $web_link = test_input($_POST["web_link"]);
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["link_title"])) {
    $link_titleErr = "**Link Title is required**";
  } else {
    $link_title = test_input($_POST["link_title"]);
        if (!preg_match("/^[a-zA-Z ]*$/",$link_title)) {
      $link_titleErr = "**Only letters and white space allowed**";
    }
  }
   if (empty($_POST["web_link"])) {
        $web_linkErr = "**Web Link is required**";
   } else {
// do nothing
  }
            if($_POST['select'] == "") {
                $type_of_linkErr = "**Type of Link is required**";
            }
            else {
               // do nothing
            }
        }

    if ($link_titleErr == '' && $web_linkErr == '' && $type_of_linkErr == '') { 
    $_SESSION['data'] = array($_POST['link_title'],$_POST['web_link'],$_POST['type_of_link']);
//header("Location: add_link.inc.php");
    }    
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add Links</title>
<link href="../styles/main.css" rel="stylesheet" type="text/css">
</head>

<div class="nav"><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
    <td width="20%" bgcolor="#980002"><div align="center"><a href="https://www.thamesvalleycoalition.co.uk/includes/admin_login.php" title="About Us" target="_self">ADMIN</a></div></td>
    <td width="20%" bgcolor="#980002"><div align="center"><a href="https://www.thamesvalleycoalition.co.uk/includes/forum.php" title="Event Diary" target="_self">FORUM</a></div></td>
    <td width="20%" bgcolor="#980002"><div align="center"><a href="https://www.thamesvalleycoalition.co.uk/includes/add_pictures.php" title="Photo Gallery" target="_self">ADD PICTURES</a></div></td>
    <td width="20%" bgcolor="#980002"><div align="center"><a href="https://www.thamesvalleycoalition.co.uk/includes/add_links.php" title="Biker Friendly" target="_self">ADD LINKS</a></div></td>
    <td width="%" bgcolor="#980002"><div align="center"><a href="https://www.thamesvalleycoalition.co.uk/includes/add_events.php" title="Links" target="_self">ADD EVENTS</a></div></td>
  </tr>
  <td height="4"></tr>
</table>
</div>
<div class="subheader">ADD LINKS</div>
<div class="header"><a href="https://thamesvalleycoalition.co.uk/includes/logout.php">logout</a></div>
<div class="content">
   <div id="links_form">

    <form action="add_link.inc.php" method="post" id="links_form">
   <fieldset>
      <legend>Add Link</legend>
  <table width="100%">
    <tbody>
      <tr>
        <td width="33%"><div>
          <div align="right">Link Title:</div>
        </div></td>
        <td width="33%"><div id="form_box">
          <input name="link_title" type="text" id="link_title" value="<?php echo $link_title;?>" size="40">
        </div></td>
        <td width="33%"><div align="left"><span class="error" style="color: red"><?php echo $link_titleErr;?></span></div></td>
      </tr>
      <tr>
        <td width="33%"><div align="right">Website Link:</div></td>
        <td width="33%"><div id="form_box">
          <input name="web_link" type="text" id="web_link" value="<?php echo $web_link;?>" size="40">
        </div></td>
        <td width="33%"><div align="left"><span class="error" style="color: red" ><?php echo $web_linkErr;?></span></div></td>
      </tr>
      <tr>
        <td width="33%"><div align="right">Type of Business or Service:</div></td>
        <td width="33%"><div id="form_box">
          <select name="select" id="select">
            <option value="">SELECT TYPE OF LINK</option>
            <option value="Pub/Restaurant">Pub/Restaurant</option>
            <option value="Shop/Store">Shop/Store</option>
            <option value="Motorcycle/Car">Motorcycle/Car</option>
            <option value="Other">Other</option>
          </select>
        </div></td>
        <td width="33%"><div align="left"><span class="error" style="color: red"><?php echo $type_of_linkErr;?></span></div></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div align="center">
          <input type="submit" name="submit" id="submit" value="Add Link" formaction="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" formmethod="post">
        </div></td>
        <td>&nbsp;</td>
      </tr>
    </tbody>
  </table>
  </fieldset>
  </form>
  </div>
  <p>&nbsp;</p>
  <div id="delete_link"><form><fieldset><legend>Delete Link</legend>
            <?php while($row = mysqli_fetch_array($result)): ?>
            <label>
              <input type="checkbox" value="<?php echo $row['linkid']; ?>" name="delete[]" />            
              <?php echo $row['linkid']; ?> - <?php echo $row['link_title']; ?> - <?php echo $row['type_of_link']?> - <?php echo $row['web_link']?> <?php echo '<br/>'?>
            </label>
            <?php endwhile; ?>
            <br>
<input name="submit" type="submit" value="Delete Link" formmethod="post" formaction="delete_link.inc.php"/>
          </p>
          <p>&nbsp;</p>
        </form>
  </form></div>
</div>


<div class="footer" >All contents on this site are Copyright of the TVC.</div>

</body>
</html>

更改此行:

if(!isset($_SESSION['login']) == '1') {

if(isset($_SESSION['login']) && $_SESSION['login'] == '1') {