|
 |
|
session มีโค้ดมาให้ดูค่ะ..ช่วยหน่อยนะคะ โค้ด chek ค่ะ มันไม่ได้ซะที ผิดตรงไหนคะ |
|
 |
|
|
 |
 |
|
//ฟอร์ม login
<?
session_start();
$host="localhost";
$user="root";
$passwd="";
$dbname="db_personal";
mysql_connect($host, $user, $passwd) or die("ติดต่อ host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
?>
<HTML>
<HEAD>
<style>
a { font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #002dd4}
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px}
p { font-family: Arial, Helvetica, sans-serif; font-size: 13px}
h1 { font-family: Arial, Helvetica, sans-serif; font-size: 18px}
h2 { font-family: Arial, Helvetica, sans-serif; font-size: 16px}
a:hover { font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #d10054; text-decoration: none}
td { font-family: Arial, Helvetica, sans-serif; font-size: 13px}
</style>
<TITLE>ระบบการจ่ายงาน-รับงาน</TITLE>
</HEAD>
<BODY bgcolor="#fff6df">
<H1>:: ระบบการจ่ายงาน-รับงาน ::</H1>
<FORM METHOD="POST" ACTION="check_user.php">
<TABLE WIDTH="260" >
<TR>
<TD><b>Username </b></TD>
<TD><INPUT NAME="username" TYPE="text" style="background-color: #ffd0a7"> <font color=red>* </font></TD>
</TR>
<TR>
<TD><b>Password </b></TD>
<TD><INPUT NAME="password" TYPE="password" style="background-color: #ffd0a7"> <font color=red>* </font></TD>
</TR>
<TR>
<TD> </TD>
<TD><INPUT NAME="submit" TYPE="submit" VALUE="Submit">
<INPUT NAME="RESET" TYPE="reset" VALUE="Reset">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
//โค้ด chek ค่ะ มันไม่ได้ซะที ผิดตรงไหนคะ
<?
$username=$_POST[username];
$password=$_POST[password];
include "connect.php";
$sql="select*from userinfo where username='$username' && password='$password'";
$dbquery=mysql_db_query($dbname,$sql);
$num_rows=mysql_num_rows($dbquery);
if (num_rows == 1) {
session_start();
session_register("sess_userid");
$sess_userid=session_id();
header("Location: home.php");
}
else
{
echo "<H3> Error : Username หรือ Password ไม่ถูกต้อง </H3>";
exit();
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-07-29 16:53:32 |
By :
bee2009 |
View :
794 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ีมันจะบอก user pass ไม่ถูกต้องอ่ะค่ะ
แก้จนงงแล้วค่ะ
ช่วยด้วยค่ะ
|
 |
 |
 |
 |
Date :
2009-07-29 16:54:30 |
By :
bee2009 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอาตัวนี้ไปใช้ดูนะครับ และก็เช็ค username กับ password ว่าตรงกับ ฐานข้อมูลหรือเปล่านะครับ
Code (PHP)
<?php
$sql2 = "Select * From userinfo Where username='$username' and password='$password' " ;
$result2 = mysql_query($sql2);
$cus = mysql_fetch_array($result2);
if ($cus['username']!="" and $cus['password']!="" )
{
$user=$cus['username'];
$name=$cus['name'];
$status="user";
$status2="name";
session_register("user");
session_register("status");
session_register("$status2");
$cus=$cus['id'];
session_register("cus");
echo "<meta http-equiv='refresh' content='0 ; URL = home.php'>";
}
else
echo "<script language='javascript'>alert('No Login');history.back();</script>";
}
?>
|
 |
 |
 |
 |
Date :
2009-07-29 17:19:33 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|