|
|
|
ช่วยด้วยครับ!!! ช่วยเขียนโค๊ด checklogin.php ให้ผมหน่อย |
|
|
|
|
|
|
|
ผมจะทำเว็บแสดงเกรด พอเวลาล็อคอินเข้าไป ไม่ว่าจะใช้user และpass เลขไหนมันก็ขึ้นไม่ขึ้นข้อมูลของแต่ละคน แต่มันขึ้นข้อมูลของคนเดียวคือคนแรกที่กรอกข้อมูลใน sql คนแรก
login.php
<?php require_once('Connections/garde.php'); ?>
<?php
mysql_select_db($database_garde, $garde);
$query_Recordset1 = "SELECT * FROM login, showgarde";
$Recordset1 = mysql_query($query_Recordset1, $garde) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['stuid'])) {
$loginUsername=$_POST['stuid'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "stuid";
$MM_redirectLoginSuccess = "doogarde.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_garde, $garde);
$LoginRS__query=sprintf("SELECT stuid, pass, stuid FROM login WHERE stuid='%s' AND pass='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $garde) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'stuid');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>login</title>
</head>
<body>
<p align="center"> </p>
<p align="center"> </p>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="292" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="185"><div align="left"><strong>เลขประจำตัวนักเรียน</strong></div></td>
<td width="107"><label>
<input name="stuid" type="text" id="stuid" value="" size="15" maxlength="5" />
</label></td>
</tr>
<tr>
<td><strong>รหัสผ่าน</strong></td>
<td><label>
<input name="pass" type="password" id="pass" size="15" maxlength="4" />
</label></td>
</tr>
<tr>
<td height="38" colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="เข้าสู่ระบบ" />
</div>
</label></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
หน้าที่จะให้เชื่อมต่อ doogarde.php
<?php require_once('Connections/garde.php'); ?>
<?php
mysql_select_db($database_garde, $garde);
$query_Recordset1 = "SELECT * FROM showgarde";
$Recordset1 = mysql_query($query_Recordset1, $garde) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="391" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="44" colspan="2"><div align="center"><strong>ผลการเรียน</strong></div></td>
</tr>
<tr>
<td>รหัสประจำตัวนักเรียน</td>
<td><label></label></td>
</tr>
<tr>
<td width="247">ชื่อ</td>
<td width="253"><label></label></td>
</tr>
<tr>
<td>นามสกุล</td>
<td><label></label></td>
</tr>
<tr>
<td>ระดับชั้น</td>
<td><label></label></td>
</tr>
<tr>
<td>ห้อง</td>
<td><label></label></td>
</tr>
<tr>
<td>ภาคการศึกษาที่</td>
<td><label></label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>ภาษาไทย</td>
<td><label></label></td>
</tr>
<tr>
<td>คณิตศาสตร์</td>
<td><label></label></td>
</tr>
<tr>
<td>วิทยาศาสตร์</td>
<td><label></label></td>
</tr>
<tr>
<td>สังคม</td>
<td><label></label></td>
</tr>
<tr>
<td>คอมพิวเตอร์</td>
<td><label></label></td>
</tr>
<tr>
<td>ภาษาอังกฤษ</td>
<td><label></label></td>
</tr>
<tr>
<td>พลศึกษา</td>
<td><label></label></td>
</tr>
<tr>
<td>สุขศึกษา</td>
<td><label></label></td>
</tr>
<tr>
<td>งานบ้าน/งานเกษตร</td>
<td><label></label></td>
</tr>
<tr>
<td>แนะแนว</td>
<td><label></label></td>
</tr>
<tr>
<td>ศิลปะ</td>
<td><label></label></td>
</tr>
<tr>
<td>ชุมนุม
<label></label></td>
<td><label></label></td>
</tr>
<tr>
<td height="27">ลูกเสือ/เนตรนารี</td>
<td> </td>
</tr>
<tr>
<td height="27"> </td>
<td> </td>
</tr>
<tr>
<td height="27">เกรดเฉลี่ย</td>
<td><label></label></td>
</tr>
<tr>
<td height="27">เกรดเฉลี่ยสะสม</td>
<td><label></label></td>
</tr>
<tr>
<td height="27"> </td>
<td><label></label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="ออกจากระบบ" />
</div>
</label></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Tag : - - - -
|
|
|
|
|
|
Date :
5 ก.ย. 2551 10:23:52 |
By :
bomp |
View :
1564 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา
session_start()
ไปอยู่บนสุดครับ
|
|
|
|
|
Date :
5 ก.ย. 2551 12:40:05 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แค่ใส่ session_start() มันจะแยก password ของแต่ละคนให้หรอครับ
ว่าใคร password อะไร กรุณาช่วยตอบด้วยครับ
|
|
|
|
|
Date :
5 ก.ย. 2551 14:23:52 |
By :
bomp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
นายต้องแยกตอน login หะครับ ว่าใครเป็นใคร
login เข้ามาแล้วนายก็แยก ใส่ตัวแปรไว้ เช่น
$sql = mysql_query("SELECT * FROM WHERE username = '$username' and pass = '$pass'");
$nums = mysql_num_rows($sql);
if($nums!=0){ // เจอค่าที่ login เข้ามา
$rs=mysql_fetch_array($sql)
{
$user = $rs[1];
$usergroup = $rs[3];
session_register('user');
seesion_register('usergroup');
}
}
|
|
|
|
|
Date :
8 ก.ย. 2551 11:03:33 |
By :
teez1232002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถึงแม้จะงงๆนิดหน่อย
แต่ต้องขอขอบพระคุณมากครับที่กรุณาตอบ
|
|
|
|
|
Date :
8 ก.ย. 2551 19:33:15 |
By :
bomp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|