我被困在如何爲登錄用戶創建會話。我得到了檢查的一部分,以確保登錄信息與數據庫信息相對應,但被困在如何採取電子郵件地址並存儲到會話中。下面是我的php代碼。創建會話用戶登錄php
<?php include '../View/header.php';
session_start();
require('../model/database.php');
$email = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT emailAddress FROM customers WHERE emailAddress ='$email' AND password = '$password'";
$result = mysql_query($sql, $db);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['emailAddress'];
}
mysql_free_result($result);
?>
你問如何存儲的電子郵件地址,即查詢結果爲會議? (此外,不需要從數據庫中獲取相同的電子郵件地址,這與您在'WHERE'子句中提供的相同)。 – Lion