我遇到一个问题,在按下提交后,我被带到一个所有源代码的页面,而不是像我预期的那样登录。
任何人都可以告诉我我的问题在哪里会很棒,我真的很困惑我希望它现在作为本地页面工作,因为我处于开发的早期阶段我是编码世界的新手但是我试着学习。
Index.html的来源:
<?php
session_start();
echo 'Connected successfully';
mysql_close($link);
if ($_POST['username']) {
$dbUsername = "james";
$dbPassword = "";
$uid = "1111";
$username = strip_tags($_POST["username"]);
$paswd = strip_tags ($_POST["password"]);
if (username == $dbusername && $paswd == $dbPassword){
$_SESSION['username'] = $username;
$_SESSION['id'] = $uid;
header("location: index.html");
} else {
echo "username and password not registered";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Rank Landlord</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="body">
<header class="mainHeader">
<div id="wrapper">
<br />
<form id="form" action="index.php" method="post" enctype="multipart/form- data">
Username: <input type="text" name="username" />
Password: <input type="password" name="password" />
<input type="submit" value="Login" name="Submit" /><br /><br />
</form>
</div>
<nav><ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="xxx.html">XXX</a></li>
<li><a href="xxxx.html">XXXX</a></li>
<li><a href="xxxxxxx.html">XXXXXXt</a></li>
<li><a href="Registration.html">Registration</a></li>
<li><a href="detailed.html">XX</a></li>
</ul></nav>
</header>
<div class="mainContent">
<div class="content">
<article class="topcontent">
<header>
<h2><a href="#" rel="bookmark" title="Permalink to this POST TITLE">Who are we?</a></h2>
</header>
<footer>
<p class="xxxxxxxxx xxxxxxxxxxx</p>
</footer>
<content>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</content>
</article>
<article class="bottomcontent">
<header>
<h2><a href="#" rel="bookmark" title="Permalink to this POST TITLE">Registration</a></h2>
</header>
<footer>
<p class="post-info">Register as a free user using social media</p>
</footer>
<content>
<p>social media logos to go here, with links</p>
</content>
</article>
</div>
<aside class="top-sidebar">
<article>
<h2>quick search</h2>
<p></p>
<div id="bottomContent">
<form class="searchform cf">
<input type="text" placeholder="Find a Landlord to RANK!">
<button type="submit">Search</button>
<p> </p>
</form>
</div>
</article>
</aside>
<aside class="middle-sidebar">
<article>
<h2>Area Search</h2>
<p>
<form class="searchform cf">
<input type="text" placeholder="Postcode..."></p>
<p>
<form class="searchform cf">
<input type="text" placeholder="City..."></p>
<p>
<form class="searchform cf">
<input type="text" placeholder="County..."></p>
<p><form action="">
<select name="Within...">
<option value="01">0-1 Miles</option>
<option value="25">2-5 Miles</option>
<option value="5-10">5-10 Miles</option>
<option value="10plus">10+ Miles</option>
</select>
<p> <button type="submit">Search</button> </p>
</article>
</aside>
</form></p>
</div>
<footer class="mainFooter">
</footer>
</body>
</html>
答案 0 :(得分:4)
将文件名从index.html
更改为index.php
,否则不会被PHP解析并执行。
还要确保从安装了PHP的Web服务器执行该文件。