PHP密码保护

时间:2012-07-21 19:10:42

标签: php forms passwords password-protection

我已经研究了这么久,我已经做了好几百次了,但我现在忘记了。最简单的事情。如何在PHP中进行密码保护。请帮助,当我点击提交时,没有任何内容弹出。这是我的代码:

<html>
<style type="text/css">
#textbox1 {
text-shadow:2px 2px 3px #000000;
}

label {
text-shadow:2px 2px 3px #000000;
font-family:"Arial";
}
</style>
</style>
<script type="text/javascript">
function clearText(target){target.value= "";}
</script>
<head>
<center>
<form action="" method="POST">
<label face="Arial">Password:  </label><input id="textbox1" type="password" name="password" value="" onfocus="clearText(this)">
<input id="button" type="submit" value="Login to Uploader">
</form>
</center>
</html>
<?php

$pass = $_POST['password'];
$submit = $_POST['submit'];

if (isset($_POST['submit'])) {
if ($pass == "pengsuploader123" || $pass="pass") {
echo "Test";
} else {
echo "Wrong!";
}
}

?>

1 个答案:

答案 0 :(得分:3)

您需要为提交按钮提供PHP的属性name="submit"以检测它。此外,$pass="pass"应为$pass == "pass"