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.

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

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。