dongxun4110 2015-07-07 22:09 采纳率: 0%
浏览 38
已采纳

php提交返回源代码?

I am having an issue where after pressing submit, I am taken to a page that is all source code rather than getting logged in like I expected.

Can anyone tell me where my issue is that would be great, I'm really confused i want it working as a local page for now as I am in very early stages of development I am new to the world of coding but am trying to learn.

Source of 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>
  • 写回答

1条回答 默认 最新

  • dongwupu5991 2015-07-07 22:11
    关注

    Change the filename from index.html to index.php otherwise it won't get parsed and executed by PHP.

    Also ensure that you are executing the file from a webserver with PHP installed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系