如何使用php登录直接实现post-get


How do you implement post-get-direct with a php login?

是post-redirect得到了一个新东西,因为没有太多我能理解的信息。。。

我的代码是你的基本php密码脚本。。

<?php
//put sha1() encrypted password here - example is 'hello'
$password = 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d';
session_start();
if (!isset($_SESSION['loggedIn'])) {
$_SESSION['loggedIn'] = false;
}
if (isset($_POST['password'])) {
if (sha1($_POST['password']) == $password) {
    $_SESSION['loggedIn'] = true;
} else {
    die ('Incorrect password');
}
} 
if (!$_SESSION['loggedIn']): ?>
<html><head><title>Login</title>
<link href="mainstyle.css" rel="stylesheet" type="text/css" title="1">
<style>
#formenclosure  {
width: 300px;
height:300px;
margin-top:50px;
margin-left:auto;
margin-right:auto;
color:fff;
}</style>
</head>
<div id="header">
    <div id="logo">
        <img src="images/zlogo1.png" width="36" height="42"
           title=<?php echo '"' . $_SERVER['HTTP_USER_AGENT'] .'"' ?>"
        >
    </div>
 <div id="enterprise">Palladium Z1 <span style="color:gold">&nbsp<?php echo $host ?></span></div> <p id='hmsg'></p>
</div>
<?php
 // Check the browser level and warn users if it looks wrong (not chrome or FF or too old an FF)
 // swap the beginning comments between the next two IF statements to see how the message looks.
if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/3.')>0
    ||(   strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')==0
       && strpos($_SERVER['HTTP_USER_AGENT'],'Chrome' )==0
      )
   ) {
 // if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/4')>0) {   /* for testing */
 //  echo "&nbsp;&nbsp; Unsupported Browser:" . $_SERVER['HTTP_USER_AGENT'] . "'n'n";
 echo "&nbsp;&nbsp; Page best viewed with Chrome or Firefox (38.5 or later).";
}
?>
</div>
<body>
<div id="formenclosure">
<fieldset>
<legend>You need to login</legend>
<form method="post">
  Password: <input type="password" name="password"> <br />
  <input type="submit" name="submit" value="Login">
</form>
</fieldset>
</div>
<div id="footer">
            <div id='cadencelogo' title='Versions: <?php echo $verall ?>' >
                <img src="images/logocadence.jpg" width="160" height="36">
            </div>
</div>
</body>
</html>
 <?php
 exit();
 endif;
 ?>

我尝试过不同的方法,但这似乎是我需要的确切方法,但它更像是一个过程,而不是一个命令。有人能帮忙吗?

只需在$_SESSION['loggedIn'] = true; 之后添加header("Location: ".$_SERVER["PHP_SELF"]);