php标题赢得了我的一个网站上的重定向

时间:2015-01-13 01:10:16

标签: php html header

我有两个内容相同的网站。一个是" .com"另一个是" .nc"。

我有这个php页面:

<?php 
// si le mot de passe est posté 
if(isset($_POST["motpasse"])){ 
  // si la valeur du mot de passe est bien celle qu'il faut 
  if($_POST["motpasse"] == "pass") { 
    header ("Location: dernier.php"); 
    exit(); 
  }else {echo "Mauvais mot de passe";} 
} 
echo ('<p align="center"><font size=6pt>Veuillez saisir 
       votre mot de passe: <br></p></font>'); 
echo '<form name="motdepasse" method="post" 
       action="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '">'; 
echo ('<p align="center"><input type=password name="motpasse" 
       size="5" style="height:60px; width:160px" value="" /></p>'); 
echo ('<p align="center"><input type="submit" 
       name="action onClick=(this.form)"  
       style="height:60px; width:160px"value="OK"></p>'); 
echo '</form>'; 
?> 

奇怪的是,标题功能正在网站上运行&#34; .com&#34;但不是在网站上#34; .nc&#34;

当我输入密码时,标题不会在我放置的php页面上重定向我(&#34; dernier&#34;)。知道为什么吗?

1 个答案:

答案 0 :(得分:0)

JackBauer告诉你发送的标题是正确的。另一个解决方案有些令人讨厌:

<?php 
// si le mot de passe est posté 
if(isset($_POST["motpasse"])){ 
// si la valeur du mot de passe est bien celle qu'il faut 
if($_POST["motpasse"] == "pass") { 
echo "<meta http-equiv="refresh" content="0;url=dernier.php">";
/*header ("Location: dernier.php"); */
exit(); 
}else {echo "Mauvais mot de passe";} 
} 
echo ('<p align="center"><font size=6pt>Veuillez saisir votre mot de passe: <br></p></font>'); 
echo '<form name="motdepasse" method="post" action="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '">'; 
echo ('<p align="center"><input type=password name="motpasse" size="5" style="height:60px; width:160px" value="" /></p>'); 
echo ('<p align="center"><input type="submit" name="action onClick=(this.form)"  style="height:60px; width:160px"value="OK"></p>'); 
echo '</form>'; 
?> 

但是,脚本中失败的主要原因可能是表单中的操作。 使用firebug在您的客户端查看您的scaped html代码。 (你在浏览器中看到的内容{font code})

见啊!