พี่ช่วยดูโค้ด Loginให้หน่อยค่ะ โค้ดหน้า Login พี่ช่วยดูโค้ดให้หน่อยค่ะ พอดีหน้า Login ยังไม่ได้ใส่ Username และ Pass กดตรงปุ่ม Login ก้อสามารถเข้าสู่ระบบได้
โค้ดหน้าLogin
<!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FFFF66;
}
body,td,th {
font-family: JasmineUPC;
}
-->
</style></head>
<body>
<form name="form1" action="login_check.php" method=''post'' >
<table width="242" height="202" border="2" bordercolor="#993333" bgcolor="#9900FF">
<tr bgcolor="#66CCFF">
<td colspan="2" bordercolor="#000000"><div align="center">
<table width="200" border="0">
<tr>
<td><div align="center"><img src="images/icons/login.jpg" width="43" height="43" /></div></td>
</tr>
</table>
<span class="style3">กรุณาใส่ชื่อและรหัสผ่าน</span></div>
</td>
</tr>
<tr bgcolor="#66CCFF">
<td width="101" bordercolor="#000000">
<span class="style1">Username:</span>
</td>
<td width="136" bordercolor="#000000">
<span class="style1">
<input name="Username" type="text" id="Username" size="15" maxlength="8" />
</span></td>
</tr>
<tr bgcolor="#66CCFF">
<td bordercolor="#000000">
<span class="style1">Password:</span>
</td>
<td bordercolor="#000000"><span class="style1">
<input name="Password" type="password" id="Password" size="15" maxlength="8" />
</span></td>
</tr>
<tr bgcolor="#66CCFF">
<td colspan="2" bordercolor="#000000"><div align="center">
<input type="submit" name="Submit" id="Submit" value="Login" /></div>
</td>
</tr>
<tr bgcolor="#66CCFF">
<td colspan="2" bordercolor="#000000"><div align="center">
(<a href="condition.php" target="mainFrame">สมัครสมาชิก</a>)</div>
</td>
</tr>
<tr bgcolor="#66CCFF">
<td colspan="2" bordercolor="#000000"><div align="center">
(<a href="forgetpass.php" target="mainFrame">ลืมรหัสผ่าน</a>)</div>
</td>
</tr>
</table>
</form>
</body>
</html>
หน้าโค้ด Login_check
<?
if ($Username=="" && $Password=="") {
echo "<h3>ERROR : กรุณากรอกข้อมูลให้ครบนะค่ะ<h3>"; exit();
}
else{
include "connect.inc.php";
$result=mysql_query("select * from member where Username='$Username' and Password='$Password'",$conn);
$num=mysql_num_rows($result);
mysql_close();
}
if($num>0) {
echo "<meta http-equiv='refresh' content='0; URL = afterlogin.php' />";
} else {
echo "<h3>ERROR : Username หรือ Password ไม่ถูกต้อง</h3>";
}
?>
หน้าโค้ด after_login
<html>
<body bgcolor="#FFFF66">
<?php
include "connect.inc.php";
$sql=mysql_query("select * from member where Name = '$Name' , Username = '$Username' , Password = '$Password ' ",$conn);
if( $Username == $Username || $Password == $Password){
echo "สวัสดีค่ะยินดีต้อนรับคุณ".$Name;
echo "</br>";
}
echo "ถ้าต้องการเข้าหน้า Menu <a href='menu.php' target='_parent'>กดที่นี่</a>";
mysql_close();
?>
</body>
</html>
หน้าโค้ดLogout
<?
session_start();
if($logout=='out')
{
session_unset($user);
session_unset($count);
session_destroy();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>:: ออกจากระบบ ::</title>
<meta http-equiv=refresh content=1;URL=index.php>
</head>
<body bgcolor="#FFFF66">
<?php
if(!isset($user))
{
echo "<div align='center'><a href='left.php'>Login</font>";
}
else
{
echo "<div align='center'>";
echo " <p><br>";
echo " <br>";
echo " <font size='3' face='MS Sans Serif, Tahoma, sans-serif'><b>ออกจากระบบเรียบร้อยแล้วคะ</b></font></p>";
echo " <p><font size='3' face='MS Sans Serif, Tahoma, sans-serif'>กรุณารอสักครู่ เพื่อกลับสู่หน้าหลัก</font><br>";
echo "<div align='center'><a href='main.php'>ออกจากระบบ</font>";
echo " <br>";
echo " </p>";
echo "</div>";
}
?>
</body>
</html>
พี่ช่วยดูโค้ดให้หน่อยค่ะ พอดีหน้าLoginยังไม่ได้ใส่UsernameและPass กดตรงปุ่มLoginก้อสามารถเข้าสู่ระบบได้ จึงอยากของโค้ดการป้องกันการเข้าสู่ระบบโดยจะต้องใส่UserและPassก่อน
หน้าafter_loginมานไม่ขึ้นชื่อผู้Loginทามไงให้ขึ้นค่ะ สุดท้ายพี่ๆมีโค้ดLockหน้าไม่ให้Backกลับจากหน้าLoginและLogout
ถ้าพี่ๆมีคำแนะนำเพิ่มเติมก้อโพสมาได้นะค่ะ Tag : - - - -
Date :
2009-11-20 12:28:36
By :
bigpig310
View :
839
Reply :
3
after_login
<?php
$Username=$_POST['Username'];
$Password=$_POST['Password'];
include "connect.inc.php";
$strSQL="SELECT * FROM member WHERE Username = '$Username' AND Password = '$Password' ";
$objQuery=mysql_query($strSQL);
$fetchArray=mysql_fetch_array($objQuery);
$Nums=mysql_num_rows($objQuery);
if( $Nums>0){
echo "รหัสผ่านไม่ตรงค่ะ ";
}else{
echo "สวัสดีค่ะยินดีต้อนรับคุณ".$fetchArray['Name'];
echo "</br>";
echo "ถ้าต้องการเข้าหน้า Menu <a href='menu.php' target='_parent'>กดที่นี่</a>";
}
mysql_close();
?>
Date :
2009-11-20 13:05:12
By :
onizike
Code (PHP)
<?
include "connect.php";
if (trim($submit)!=""){
$sql="select * from tuser where user='".trim($user)."' and password='".trim($password)."' ";
$re=mysql_query($sql) or die(error());
$num=mysql_num_rows($re);
if($num>0){
session_start();
session_register("Fn");
$row=mysql_fetch_array($re);
$_SESSION['Fn'] = $row['fullname'];
header("Location:frame.php");
}else{
header("Location:index.php");
}
}else{
?>
<Center>
<Br><Br><Br><H1>
You Can't Access this page .
</H1>
<a href="index.php">Plaese Login.</a>
<?
}
?>
Date :
2009-11-20 13:26:49
By :
Sek-Artdrinker
Load balance : Server 02