Home  >  Article  >  Backend Development  >  初学者写的留言板登陆代码各位大神帮小弟我看看,为什么要点击登陆两次才能登陆,为什么要点击两次退出才能退出

初学者写的留言板登陆代码各位大神帮小弟我看看,为什么要点击登陆两次才能登陆,为什么要点击两次退出才能退出

WBOY
WBOYOriginal
2016-06-13 12:42:211186browse

菜鸟写的留言板登陆代码各位大神帮我看看,为什么要点击登陆两次才能登陆,为什么要点击两次退出才能退出?
菜鸟写的留言板登陆代码各位大神帮我看看,为什么要点击登陆两次才能登陆,为什么要点击两次退出才能退出?问题出在哪里,大神帮我看看,先谢谢你了。代码如下:

<?php<br />
include("Sql.php");<br />
if ($_GET[out])<br />
{<br />
  setcookie("cookie","out");<br />
  echo "<script language=\"javascript\">localhost.href='login.php';</script>";<br />
}<br />
if ($_POST[id]=='xxx')<br />
  {<br />
   $pw=md5($_POST[pw]);<br />
   if($pw=='e1bfd762321e409cee4ac0b6e841963c')<br />
       {<br />
         setcookie("cookie","ok");<br />
          echo "<script language=\"javascript\">localhost.href='login.php';</script>";<br />
       }<br />
  }<br />
include("Head.php");<br />
if ($_COOKIE['cookie']!='ok'){<br />
?><br />
<br />
<SCRIPT language=javascript><br />
function Checklogin()<br />
  {<br />
     if (myform.id.value=="")<br />
     {<br />
        alert ("请填写登陆名");<br />
        myform.id.focus();<br />
        return false;<br />
     }<br />
      if (myform.pw.value=="")<br />
     {<br />
        alert ("密码不能为空");<br />
        myform.pw.focus();<br />
        return false;<br />
     }<br />
  }<br />
</SCRIPT><br />
<br />
 <form action="" method="post" name="myform" onsubmit="return Checklogin();"><br />
  ID:<input type="text" name="id" ><br><br />
  PW:<input type="password" name="pw"> <input type="submit" name="submit" value="登陆" ><br />
 </form><br />
<?<br />
}else{<br />
?><br />
  <a href='?out=login'>退出</a><br />
<?<br />
}<br />
?>

PHP 菜鸟写的代码
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn