header("Location: ".$session->referrer);


header("Location: ".$session->referrer);

新手问题抱歉。

我下载了一个脚本进行测试,发现在提交表单后会打开一个新的页面/选项卡。我更喜欢在同一窗口中打开它。

我推测这句话会影响它,但不确定,任何建议都是好的。

header("Location: ".$session->referrer);

表单

<form  class="form-signin" action="process.php" method="POST"> 
    <label for="inputEmail" class="sr-only">Username</label>
    <input type="text" name="user" value="<?php echo $form->value("user"); ?>" class="form-control" placeholder="Username" required autofocus>
        <?php echo $form->error("user"); ?>
    <label for="inputPassword" class="sr-only">Password</label>
    <input type="password" name="pass" value="<?php echo $form->value("pass"); ?>"class="form-control" placeholder="Password" required>
    <?php echo $form->error("pass"); ?>
    <div class="row">
        <div class="col-xs-6"><input type="checkbox" name="remember" <?php if($form->value("remember") != ""){ echo "checked"; } ?>></div><div class="col-xs-6">Remember me [<a href="forgotpass.php">Forgot Password?</a>]</div>
    </div>
    <input type="hidden" name="sublogin" value="1">
    <input class="btn btn-lg btn-primary btn-block" type="submit" value="Login">
</form>

和过程

class Process
{
   /* Class constructor */
   function Process(){
      global $session;
      /* User submitted login form */
      if(isset($_POST['sublogin'])){
         $this->procLogin();
      }
      /* User submitted registration form */
      else if(isset($_POST['subjoin'])){
         $this->procRegister();
      }
        /* User submitted registration form */
      else if(isset($_POST['member_subjoin'])){
         $this->procMemberRegister();
      }
          /* User submitted registration form */
      else if(isset($_POST['master_subjoin'])){
         $this->procMasterRegister();
      }
          /* User submitted registration form */
      else if(isset($_POST['agent_subjoin'])){
         $this->procAgentRegister();
      }
      /* User submitted forgot password form */
      else if(isset($_POST['subforgot'])){
         $this->procForgotPass();
      }
      /* User submitted edit account form */
      else if(isset($_POST['subedit'])){
         $this->procEditAccount();
      }
      /**
       * The only other reason user should be directed here
       * is if he wants to logout, which means user is
       * logged in currently.
       */
      else if($session->logged_in){
         $this->procLogout();
      }
      /**
       * Should not get here, which means user is viewing this page
       * by mistake and therefore is redirected.
       */
       else{
          header("Location: main.php");
       }
   }

如果<form>标记具有target属性,并且其值为在新页面上提交的_blank

请参考此。