【发布时间】:2016-05-09 18:33:29
【问题描述】:
美好的一天! 我正在尝试创建一个网站,您只能通过首先在首页输入密码来访问它(www.mywebsite.com/index.php)
一旦我输入密码,它将从我的 public_html 之外获取文件 home.html。
然后在该页面(home.html) 中将有使用变量 z (www.mywebsite.com/index.php?z=one) 的链接,该变量将返回 1.html 或其他页面。
这是我到目前为止尝试过的,但即使我使用 www.mywebsite.com/index.php?z=one 它仍然打开 home.html 我能得到一些帮助吗?和/或我正在尝试的可能吗?
<?php
$pass = $_POST['pass'];
if ($pass == "1234") {
$page = $_GET['z'];
if ($page == "one") {
include("../1.html");
} else {
include("../home.html");
}
} else {
if (isset($_POST)) {
?>
<!DOCTYPE html>
<html lang="en">
<form role="form" method="POST" style="margin: 0px" action="index.php">
<input type="password" name ="pass" class="form-control" id="pwd"> </input>
<input type="submit" class="btn btn-danger" value="Enter"></input>
</form>
</html>
<?php
}
}
?>
【问题讨论】:
-
良好的代码缩进有助于提高可读性,但更重要的是调试