标题(“位置:”。$ session-> referrer);

时间:2015-11-14 10:16:04

标签: php session

新手问题抱歉。

我已经下载了一个测试脚本,发现在提交表单后会打开一个新页面/标签页。我更喜欢它在同一个窗口打开。

我认为这条线正在影响它,但不确定,任何建议都是好的。

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");
       }
   }

1 个答案:

答案 0 :(得分:1)

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

请参阅this