|
|
|
ขอตั้งใหม่อีกทีนะครับ จะได้ไม่งง ครับ เกี่ยวกับการทำ Password sqlsrv |
|
|
|
|
|
|
|
ผมลอง ปรับดู Code ประมาณนี้ ยังไม่ได้อ่ะครับ
Error Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given ช่วยด้วนครับ
Code (PHP)
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "";
$userName = "";
$userPassword = "";
$dbName = "";
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT * FROM USER WHERE Username = 'txtUsername' AND Password = 'txtPassword ";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query = sqlsrv_query( $conn, $sql , $params, $options);
?>
<?php
while($result = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
if(!$result)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $result["UserID"];
$_SESSION["Status"] = $result["Status"];
session_write_close();
if($result["Status"] == "ADMIN")
{
header("location:add1.php");
}
else
{
header("location:makeredit.php");
}
}
}
?>
|
|
|
|
|
Date :
2016-07-04 08:32:10 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช่ผมลืมใส่ แต่ก็ยัง Error เหมือนเดิมเลยครับ ไม่รู้จะแก้ หรือ เพิ่มตรงไหนนะครับ
Error Notice: Undefined variable: result in
|
ประวัติการแก้ไข 2016-07-04 09:39:37
|
|
|
|
Date :
2016-07-04 09:24:22 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ขอบคุณทุกคำตอบนะครับ
Code (PHP)
<?php
session_start();
$serverName = "";
$userName = "";
$userPassword = "";
$dbName = "";
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
die( print_r( sqlsrv_errors(), true));
}
$a= $_POST['txtUsername'];
$b=$_POST['txtPassword'];
// echo $a." ".$b;
$sql = "SELECT * FROM USERS WHERE Username = '".$a."' AND Password = '".$b."' ";
// echo $sql;
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query = sqlsrv_query( $conn, $sql ,$params,$options);
$numrow=sqlsrv_num_rows($query);
//echo $numrow;
//echo $query;
$result = sqlsrv_fetch_array($query);
if(!$result)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $result["UserID"];
$_SESSION["Status"] = $result["Status"];
session_write_close();
if($result["Status"] == "ADMIN")
{
header("location:");
}
else
{
header("location:");
}
}
sqlsrv_close( $conn);
?>
|
ประวัติการแก้ไข 2016-07-04 17:20:57
|
|
|
|
Date :
2016-07-04 17:19:52 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2016-07-04 17:39:09 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|