嘿,任何人都可以查看我的代码并帮助我...我正在使用 apache,如果用户输入错误的密码和用户名 3 次,它只会将它们转发到 404 html 页面。不幸的是,我的浏览器中显示了一些代码,我不确定为什么。我知道 php,所以如果代码草率或不正确,请不要缠着我。
登录.php:
<?php
session_start();
$_SESSION['wrong']=0;
$user = $_POST['user'];
$pass = $_POST['pass'];
if($user == "school"
&& $pass == "homework")
{
echo"Password system work!";
}else{
$_SESSION['wrong']=$_SESSION['wrong']+1;
header( 'Location: http://localhost' ) ;
}
?>
索引.html:
<? session_start();
include 'login.php';
global $_SESSION['wrong'];
if($_SESSION['wrong']>=3){
header( 'Location: 404_File_Not_Found.html' ) ; //This is what the browser is showing
}
?>
<html>
<head>
<style type="text/css">
#form{
width: 340px;
height: 400px;
box-shadow: 0px 2px 5px rgba(0,0,0,0.25);
position: relative;
-webkit-box-shadow: 0px 2px 5px;
border: solid 1px #ddd;
padding: 30px 30px 60px 30px;
background: #fff;
border-radius: 10px;
}
p{
font-family: Verdana;
}
div{
margin-left:auto;
margin-right:auto;
margin-top:5%;
}
img{
width: 120;
height: 133;
left: 100px;
position: relative;
}
input{
margin-left:10%;
margin-right:5%;
font-size: 14px;
width: 264px;
padding: 9px 7px 7px;
background: none !important;
position: relative;
z-index: 10;
margin-bottom: 20px;
border-radius: 5px;
}
.button:hover{
color: red;
}
</style>
</head>
<body>
<div id="form">
<img src="http://traceybaptiste.files.wordpress.com/2011/01/homework2.jpg" />
<form method="POST" action="login.php">
<p>User:</p> <input type="text" name="user"></input>
<p>Pass:</p> <input type="password" name="pass"></input>
<input type="submit" name="submit" class="button"></input>
</form>
</div>
</body>
</html>
404.html:
<html>
<head>
<style>
html{
background-color:grey;
}
body{
background-image:url("404.jpg");
background-repeat:no-repeat;
margin-left: 25%;
margin-right: auto;
margin-top: 10%;
}
</style>
</head>
<body>
</body>
</html>