我正嘗試使用PHP/Html/MySql創建一個簡單的登錄/註冊表單。我已經成功創建了註冊表單(提交給我的數據庫),但是我不太確定如何執行部分日誌。以下是我迄今爲止所嘗試的。簡單的PHP登錄頁面幫助 - PHP,MySql,HTML
我有兩個模型,除了我的Database.php模型(持有數據庫連接),客戶端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;
}
}
ClientDataSet.php
<?php
require_once('Models/Database.php');
require_once ('Models/ClientData.php');
class ClientDataSet{
protected $_dbHandle, $_dbInstance;
public function __construct() {
$this->_dbInstance = Database::getInstance();
$this->_dbHandle = $this->_dbInstance->getdbConnection();
}
public function createClient($email, $password){
$sqlQuery='INSERT INTO mydatabase_Client (Email, Password,) VALUES ('. "'$email'".','. "'$password'".')';
//echo $sqlQuery;// useful check to see what Query has been created
$statement = $this->_dbHandle->prepare($sqlQuery); // prepare a PDO statement
$statement -> execute();
}
public function fetchClient($email, $password){
$sqlQuery='SELECT * FROM mydatabase_Client WHERE (Email='. "'$email'".', Password='. "'$password'".')';
//echo $sqlQuery;// useful check to see what Query has been created
$statement = $this->_dbHandle->prepare($sqlQuery); // prepare a PDO statement
$statement -> execute();
}
}
的login.php
<?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');
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>
你似乎缺少您的打開和關閉形式的標籤? –
你的權利,我已經加入:) – user2904529