|
|
|
ฟังก์ชั่น mysqli_stmt_get_result() ใช้ฟังก์ชั่นไหนแทนได้มั่งคะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
require 'connectdb.php';
$login_username = mysqli_real_escape_string($dbcon,$_POST['username']);
$login_password = mysqli_real_escape_string($dbcon,$_POST['password']);
$salt = 'tikde78uj4ujuhlaoikiksakeidke';
$hash_login_password = hash_hmac('sha256', $login_password, $salt);
$sql = "SELECT * FROM tblogin WHERE login_username=? AND login_password=?";
$stmt = mysqli_prepare($dbcon, $sql);
mysqli_stmt_bind_param($stmt,"ss", $login_username,$hash_login_password);
mysqli_execute($stmt);
$result_user = mysqli_stmt_get_result($stmt);
if ($result_user->num_rows == 1) {
session_start();
$row_user = mysqli_fetch_array($result_user,MYSQLI_ASSOC);
$_SESSION['login_id'] = $row_user['login_id'];
header("Location: main.php");
} else {
echo "ผู้ใช้หรือรหัสผ่านไม่ถูกต้อง";
}
ตรงบรรทัดที่ 14 พออัพขึ้น server แล้ว server บอกไม่รู้จัก แก้ยังไงดีคะ
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2016-05-06 13:24:18 2016-05-06 13:24:40
|
|
|
|
|
Date :
2016-05-06 13:23:42 |
By :
timtimtim |
View :
1457 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quote:get_result ครับ
Code (PHP)
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "root";
$dbName = "mydatabase";
$conn = new mysqli($serverName,$userName,$userPassword,$dbName);
$strCustomerID = "C001";
$sql = "SELECT * FROM customer WHERE CustomerID = ? ";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $strCustomerID); // s - string, b - blob, i - int, etc
/*** for 2 Parameters
$strCustomerID = "C001";
$strEmail = "[email protected]";
$sql = "SELECT * FROM customer WHERE CustomerID = ? AND Email = ? ";
$stmt = $conn->prepare($sql);
$stmt->bind_param('ss', $strCustomerID,$strEmail); // s - string, b - blob, i - int, etc
**/
$stmt ->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
if($row)
{
echo $row["CustomerID"]."<br>";
echo $row["Name"]."<br>";
echo $row["Email"]."<br>";
echo $row["CountryCode"]."<br>";
echo $row["Budget"]."<br>";
echo $row["Used"]."<br>";
}
$conn->close();
?>
|
|
|
|
|
Date :
2016-05-07 07:57:22 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|