|
|
|
ต้องการแยกประเภทของผู้ใช้เวลา Login เข้ามาค่ะ แต่พอเขียนโค้ดตามนี้ มันไม่แยกให้ตามที่ต้องการค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start();
$_SESSION['sess_userid']=session_id();
$_SESSION['sess_username']=$_POST["user_reg"]; //ต้องเป็นตัวแปรที่เรารับค่ามาน๊ะ
?>
<?php
$user_login=$_POST["user_reg"];
$pass_login=$_POST["pass_reg"];
include("connect.php");
$connect=mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("test_fu",$connect);
$result=mysql_query("select * from user where user_name='$user_login' and user_pass='$pass_login'",$connect);
$num=mysql_num_rows($result);
if($num<=0) {
echo "<h3>กรุณา Login ใหม่ เนื่องจาก Username หรือ Password ของคุณไม่ถูกต้อง<br></h3>";
$result2=mysql_fetch_row($result);
$_SESSION['sess_newid']=$result2['1'];
exit() ;
}
else {
include("connect.php");
$connect=mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("test_fu",$connect);
$result=mysql_query("select * from user where user_name='$user_name'",$connect);
$num=mysql_num_rows($result);
$result1=mysql_fetch_row($result);
$string = substr($result1[1],0,1);
if ($result=="A") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web47.php'>";
}
else if ($result=="T") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web3.php'>";
}
else {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web48.php'>";
}
exit();
}
?> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="22" colspan="2" valign="top"><img src="footer1 copy.jpg" width="861" height="70" /></td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS
|
|
|
|
|
|
Date :
2012-10-12 21:53:30 |
By :
yah |
View :
1175 |
Reply :
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไม mysql_connect เยอะจังครับ
|
|
|
|
|
Date :
2012-10-12 22:32:28 |
By :
maxairzoom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
//อยากทราบโค้ดส่วนนี้ค่ะ ทำไมยังใช้การไม่ได้ หรือมีวิธีไหนที่ดีกว่านี้อีกคะ
include("connect.php");
$connect=mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("test_fu",$connect);
$result=mysql_query("select * from user where user_name='$user_name'",$connect);
$num=mysql_num_rows($result);
$result1=mysql_fetch_row($result);
$string = substr($result1[1],0,1);
if ($result=="A") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web47.php'>";
}
else if ($result=="T") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web3.php'>";
}
else {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web48.php'>";
}
exit();
}
?>
|
|
|
|
|
Date :
2012-10-12 22:46:53 |
By :
yah |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result มันของ mysql_query นี่ครับ IF ผิดตัวหรือเปล่าครับ
|
|
|
|
|
Date :
2012-10-12 22:59:08 |
By :
maxairzoom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ประมาณนี้รึเปล่าคะ แต่ลองหลายแบบ หลายครั้งมากแล้ว ยังไม่ได้ค่ะ
รบกวนแนะให้ด้วยน๊ะคะ ขอบคุณมาก ๆ ค่ะ
ใช้ phpMyAdmin 3.4.5 ค่ะ
Code (PHP)
include("connect.php");
$connect=mysql_connect("localhost","root","") or die (mysql_error());
$result=mysql_query("select user_id from user where user_id='$user_id'",$connect);
$string = substr($result,0,1);
if ($result[user_id]=="A") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web47.php'>";
}
else if ($result[user_id]=="T") {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web3.php'>";
}
else {
echo "<META HTTP-EQUIV='Refresh' CONTENT='0.1;URL=web48.php'>";
}
|
|
|
|
|
Date :
2012-10-13 00:00:53 |
By :
yah |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ดเดิมอ่ะ ลองไปรันอีกเครื่องนึง ผ่านฉลุยเลยค่ะ
แต่ทำไมเครื่องหนูรันไม่ได้คะ
|
|
|
|
|
Date :
2012-10-13 00:07:36 |
By :
yah |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
mysql_connect("localhost","root","root");
mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."'
and Password = '".trim($_POST['txtPassword'])."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Username and Password Incorrect!";
}
else
{
$_SESSION["UserID"] = $objResult["UserID"];
$_SESSION["Status"] = $objResult["Status"];
session_write_close();
if($objResult["Status"] == "ADMIN")
{
header("location:admin_page.php");
}
else
{
header("location:user_page.php");
}
}
mysql_close();
?>
PHP MySQL กับ Login Form ทำระบบ User ล็อกอิน แบบง่าย ๆ ด้วย PHP และ MySQL โดยทำการตรวจสอบ Username และ Password
|
|
|
|
|
Date :
2012-10-13 11:42:58 |
By :
pokultra |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phpMyAdmin 3.4.5 ค่ะ
|
|
|
|
|
Date :
2012-10-13 16:44:31 |
By :
yah |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-01-19 16:40:31 |
By :
fs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-01-19 22:57:23 |
By :
leksoft |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเช็ด 2 อย่างครับ
1 user password สองเครื่องที่คุณว่าใช้ได้ ใช้ไม่ได้ตรงกันรึเปล่า ข้อมูลเหมือนกัน ?
2 เปลี่ยนการเปิด <? เป็น <?php ครับ แบบเดิมเค้ายกเลิกไปแล้ว บางเครื่องจะไม่ทำงาน
4 เขียน config ไว้ในไฟล์แล้ว include มาทีหลังจะดูแลง่ายกว่าเวลาเปลี่ยนเครื่อง
5 ถ้าได้แล้วลองเขียน redirect แบบ http://php.net/manual/en/function.header.php ดูครับ จะเป็นวิธีที่ดีกว่า
|
|
|
|
|
Date :
2013-01-27 13:09:39 |
By :
พิชญ์ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|