PHP提交返回源代码



我有一个问题,在按下提交后,我被带到一个页面,这是所有的源代码,而不是像我预期的那样登录。

谁能告诉我我的问题在哪里,那将是伟大的,我真的很困惑,我希望它作为一个本地页面工作,因为我现在在开发的早期阶段,我是新的编码世界,但我试图学习。

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>

将文件名从index.html更改为index.php,否则PHP将无法解析和执行。