【发布时间】:2013-01-27 01:47:54
【问题描述】:
我有一个简单的 php - 基于有效表单的密码保护/登录。 PHP代码在页面“secure.php”中,当用户+密码正确时包含html文件“accessed.html”。
但我希望在显示隐藏页面 (accessed.html) 时隐藏表单。 我尝试将表单包装在 div 中并使用 javascript 和 display: none 隐藏,但它不起作用 - 不是在本地或在服务器上。
我做错了什么?登录后不一定是js隐藏表单..
PHP 在顶部
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
if($user == "a"
&& $pass == "a")
{
include("accessed.html");
echo "<script>
document.getElementById('wrap').style.display = 'none';
</script>";
}
if(isset($_POST))
?>
还有正文中的表格:
<div id="wrap">
<form method="POST" action="secure.php">
User <input type="text" name="user"></input>
Pass <input type="text" name="pass"></input>
<input type="submit" name="submit" value="access page"></input>
</form>
</div>
【问题讨论】:
-
PHP 在服务器端运行。 Javascript 在客户端运行。这是 Web 开发的一个基本且重要的方面。
标签: php javascript