|
|
|
สอบถามเกี่ยวกับ PHP MySQL กับ Login Form ทำระบบ User ล็อกอิน มันมีปัญหาค่ะ ช่วยดูให้หน่อยนะค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
ob_start();
session_start();
session_destroy();
?>
<html>
<body>
<form name="form1" method="post" action="Sample2.php">
Login <br>
<table width="27%" border="0" cellspacing="0" cellpadding="0" height="27">
<tr>
<td>User-Name</td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td>password</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="Submit" value="login">
</td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2011-08-27 22:51:25 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่รู้ระบบมีปัญหายังไง แต่ที่แน่ๆ คำถามน้องมีปัญหามากๆ ครับ
|
|
|
|
|
Date :
2011-08-27 23:02:02 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
ob_start();
session_start();
session_destroy();
?>
<html>
<body>
<form name="form1" method="post" action="Sample2.php">
Login <br>
<table width="27%" border="0" cellspacing="0" cellpadding="0" height="27">
<tr>
<td>User-Name</td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td>password</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="Submit" value="login">
</td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2011-08-27 23:27:59 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยดูให้หน่อยนะค่ะ
|
ประวัติการแก้ไข 2011-08-27 23:39:25
|
|
|
|
Date :
2011-08-27 23:30:58 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นี้เปนฐานข้อมูลใน database ค่ะ
|
|
|
|
|
Date :
2011-08-27 23:43:38 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยแนะนำวิธีให้หนูหน่อยนะค่ะ หนูทำยังไงก็ไม่ได้สักที
|
|
|
|
|
Date :
2011-08-27 23:45:20 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlaKriM
ช่วยดูให้หนูหน่อยนะค่ะ
|
|
|
|
|
Date :
2011-08-27 23:47:20 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแก้ไขดูแล้ว มันกลายเปนแบบนี้ค่ะ
ช่วยแนะนำวิธีแก้ไขให้หน่อยนะค่ะ
|
|
|
|
|
Date :
2011-08-28 00:06:12 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น้องครับ น้องให้แต่ฟอร์มมาอะครับ เทวดาที่ไหนก็ช่วยไม่ได้อะจ้า
Sample2.php เอามาดูหน่อยครับ
|
|
|
|
|
Date :
2011-08-28 02:07:57 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sample 2
อยากให้ช่วยบอกแนะแนววิธีการทำ logout ให้หน่อยนะค่ะ
ว่าสร้างไว้ตรงไหน
Code (PHP)
<?
$host="localhost";
$username="root";
$pass_word="root";
$db="phplogin";
$tb="login";
mysql_connect( $host,$username,$pass_word) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql = "select * from $tb where user='$user' and pass='$pass'";
$dbquery = mysql_db_query($db, $sql);
$num_rows = mysql_num_rows($dbquery);
if(empty($num_rows))
{
echo"<br><center>user หรือ password ไม่ถูกต้อง</center></br>";
}
else
{
Session_register("user");
header('location:Sample3.php');
}
?>
|
|
|
|
|
Date :
2011-08-28 12:15:59 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อยากทำ logout จาก sample2 นะค่ะ แต่ไม่รู้จะเริ่มเขียนตรงไหนดี ท่านทั้งหลายโปรดช่วยหนูทีนะค่ะ
โคด sample2 อยู่ด้านบนนะค่ะ
|
|
|
|
|
Date :
2011-08-28 12:18:52 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเปลี่ยนเป็น แล้วดูว่า error ไหม
สิ่งที่อยากให้เปลี่ยนคือควรใช้ $_POST แล้วก็ Session_register เขาไม่นิยมใช้กันแล้ว ผมว่าไปอ่านบทเรียนแล้วลองทำตามดีกว่านะ
Code (PHP)
<?
$host="localhost";
$username="root";
$pass_word="root";
$db="phplogin";
$tb="login";
mysql_connect( $host,$username,$pass_word) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql = "select * from $tb where user='$user' and pass='$pass'";
$dbquery = mysql_db_query($db, $sql) or die(mysql_error() . '<br/>' . $sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows <= 0)
{
echo"<br><center>user หรือ password ไม่ถูกต้อง</center></br>";
}
else
{
Session_register("user");
header('location:Sample3.php');
}
?>
|
|
|
|
|
Date :
2011-08-28 12:28:59 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
ob_start();
$host="localhost";
$username="root";
$pass_word="root";
$db="phplogin";
$tb="login";
$connect = mysql_connect( $host,$username,$pass_word) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
$obj_db = mysql_select_db($db,$connect) or die("เลือกฐานข้อมูลไม่ได้");
$user = trim($_POST['user']);
$pass = trim($POST['pass']);
$sql = "select * from $tb where user='$user' and pass='$pass'";
$dbquery = mysql_db_query($db, $sql) or die(mysql_error() . '<br/>' . $sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows <= 0)
{
echo"<br><center>user หรือ password ไม่ถูกต้อง</center></br>";
}
else
{
$_SESSION['user'] = $user;
header('location:Sample3.php');
}
?>
|
|
|
|
|
Date :
2011-08-28 13:42:12 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณทุกๆๆคนที่ให้คำแนะนำนะค่ะ
|
|
|
|
|
Date :
2011-08-28 14:23:00 |
By :
Moo_mickey20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|