简单PHP登录页面帮助-PHP、MySql、HTML

简单PHP登录页面帮助-PHP、MySql、HTML,php,html,mysql,database,login,Php,Html,Mysql,Database,Login,我正在尝试使用PHP/Html/MySql创建一个简单的登录/注册表单。我已经成功地创建了注册表(提交到我的数据库),但是我不太确定如何进行部分登录。下面是我到目前为止所做的尝试 除了Database.php模型(保持db连接)、Client Data.php和ClientDataSet.php之外,我还有两个模型 一个login.php页面和一个login.phtml页面 ClientData.php如下所示: <?php require_once('Models/

我正在尝试使用PHP/Html/MySql创建一个简单的登录/注册表单。我已经成功地创建了注册表(提交到我的数据库),但是我不太确定如何进行部分登录。下面是我到目前为止所做的尝试

除了Database.php模型(保持db连接)、Client Data.php和ClientDataSet.php之外,我还有两个模型 一个login.php页面和一个login.phtml页面

ClientData.php如下所示:

       <?php
    require_once('Models/Database.php');
    require_once ('Models/ClientDataSet.php');

    class ClientData {

    private $email, $password;

    public function __construct($dbRow) {
    $this->email = $dbRow['Email'];
    $this->password = $dbRow['Password'];  
    }    

    public function getEmail() {
    return $this->email;
    }

    public function getPassword() {
    return $this->password;
    }
} 

登录页面
如果您尚未注册

使用您的电子邮件地址和密码登录

电邮: 密码:
首先,不要连接字符串来构建查询。在mysql中使用PDO时,应该使用参数绑定。创建SQL语句的方式使您极易受到SQL注入攻击

请看这里:

现在,谈谈您的实际问题:您没有使用HTML表单。您必须使用正确的表单参数将输入元素包装到表单中,否则浏览器将不会向服务器发送任何数据

它看起来像这样:

 <form name="login" action="html_form_action.php" method="post">


进一步阅读:

您似乎丢失了开始和结束表单标签?您的权利,我添加了:)谢谢。我不太担心攻击,因为这只是我正在做的一个个人项目——不可能很快公开:)好吧,尽管养成好习惯是个好主意,以防你做不同的项目。如果该部分有帮助,请接受答案。它可能是私人的和本地的,但从一开始最佳实践将不会损害,但会提高知识和代码。
        <?php 
require_once('Models/Database.php');
require_once('Models/ClientData.php');
require_once('Models/ClientDataSet.php');
session_start();

$view = new stdClass();
$view->pageTitle ='Login';

if(isset($_POST['submit'])) {      
        $clientDataSet= new ClientDataSet();
        $clientDataSet->fetchClient($_POST['Email'], $_POST['Password']);
} ?>

<?php

require_once('Views/login.phtml'); 
<?php require('template/header.phtml') ?>
<h3>Login Page</h3>
<p>If you have not already Registered. <a href="register.php">Register Here.</a></p>
    <p><strong>Login</strong> using your <strong>email address</strong> and password.</p>
    <table class="inputtable">
        <tr>
            <td class="label">Email:</td>
            <td class="inputtd">
                <input name="Email" type="email" class="standardwidth" /></td>
        </tr>
        <tr>
            <td class="label">Password:</td>
            <td class="inputtd">
                <input name="Password" type="password" class="standardwidth" /></td>
        </tr>
    </table>
    <div>
        <input type="submit" value="Login" name="submit"/> <input type="reset" value="Reset" name="reset"/>
    </div>
 <form name="login" action="html_form_action.php" method="post">