ช่วยทีนะคะ หน้าlogin อ่ะ คือเขียน php ผสมก่ะ html จะทำหน้าlogin อ่ะค่ะ โดยให้เช็คว่าถ้าเป็น user
คือเขียน php ผสมก่ะ html จะทำหน้าlogin อ่ะค่ะ โดยให้เช็คว่าถ้าเป็น user จะเข้าไปหน้าสำหรับuser
ถ้าเป็นหน้าadmin สามารถดูได้ทุกหน้าอ่ะค่ะ จะต้องเขียนcode ยังไง แล้วใส่ไว้ตรงไหนอ่ะคะ
เพิ่งเริ่มหัดทำอ่ะค่ะ รบกวนช่วยทีนะคะ นี่codeที่เขียนไว้อ่ะค่ะ
<?php require_once('../Connections/db_register.php'); ?>
<?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['logname'])) {
$loginUsername=$_POST['logname'];
$password=$_POST['psw'];
$MM_fldUserAuthorization = "username";
$MM_redirectLoginSuccess = "show_file.php";
$MM_redirectLoginFailed = "loginfailed.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_db_register, $db_register);
$LoginRS__query=sprintf("SELECT username, password, username FROM members WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $db_register) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'username');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<font face="Arial, Helvetica, sans-serif"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
</font>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>UHTML Table</title>
<style type="text/css">
<!--
body {
background-image: url();
background-color: #cef8f2;
}
body,td,th {
font-size: 14px;
}
.style1 {
color: #FF00CC;
font-weight: bold;
}
.style2 {color: #3333FF}
-->
</style></head>
<body>
<table width="1029" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="6"><img src="image/head.gif" width="1024" height="134"></td>
</tr>
<tr>
<td width="254"> </td>
<td width="155"> </td>
<td width="155"> </td>
<td width="155"> </td>
<td width="155"> </td>
<td width="155"> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p class="style1 style2"><font face="Arial, Helvetica, sans-serif">พิมพ์ชื่อและรหัสผ่านเพื่อล็อกอินเข้าระบบ</font></p>
<p> </p>
<form action="<?php echo $loginFormAction; ?>" method="POST" name="form_login" id="form_login">
<div align="left">
<table width="987" height="138" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="289" nowrap> </td>
<td width="289" nowrap bgcolor="#9DFDE8"><div align="center">
<p><font face="Arial, Helvetica, sans-serif">user name
<input name="logname" type="text" id="logname">
</font></p>
<p><font face="Arial, Helvetica, sans-serif">password
<input name="psw" type="password" id="psw">
</font></p>
<p> <font face="Arial, Helvetica, sans-serif">
<input type="submit" name="Submit" value="login">
<input name="cancle" type="submit" id="cancle" value="Cancel">
</font></p>
</div></td>
<td width="300"> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
<font face="Arial, Helvetica, sans-serif"></font>Tag : - - - -
Date :
12 ก.ย. 2550 09:45:00
By :
jaja
View :
2175
Reply :
2
ก็ใช้วิธีเช็คตรงเมนู หลังจากที่ login เข้าไปแล้ว ว่า user หรือ admin สามารถใช้เมนูไหนได้บ้าง
Date :
12 ก.ย. 2550 10:07:48
By :
tot
session ช่วยได้
Date :
12 ก.ย. 2550 18:34:28
By :
มือเก่าแต่ไม่เก๋า
Load balance : Server 04