 |
|
|
 |
 |
|
ก็เอารหัสผ่านที่ส่งมา เข้ารหัส md5 ก่อนนำไปเทียบค่ะ
|
 |
 |
 |
 |
Date :
2010-05-04 15:30:31 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาเข้าไปตอนไหนอะงับ ใส่ code อยางงัยหรองับ
|
 |
 |
 |
 |
Date :
2010-05-04 15:32:35 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$user_login=$_POST['user_login'];
$pass_login=$_POST['pass_login'];
$pass_login=md5($pass_login); #เอาค่าที่รับมาแปลงเป็น md5() ก่อน แล้วค่อยเอาไปเปรียบเทียบครับ

|
 |
 |
 |
 |
Date :
2010-05-04 16:06:39 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$username=$_POST["id"];
$pass=$_POST["pass"];
$password=md5($pass);
$sql=mysql_query("select * from school where ID ='$username' and Pass ='$password'");
|
 |
 |
 |
 |
Date :
2010-05-04 16:18:55 |
By :
LuckyStar |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอลองไป ทำ ก่อนนะครับ ได้ไม่ได้เดียวมาบอก อีกที นะครับ ขอบคุงมากๆ งับ ^^
|
 |
 |
 |
 |
Date :
2010-05-04 21:10:51 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แง้วๆ ยางมะได้เลยอะงับ มันยังเปงเหมือนเดิมอะครับ คือมันไม่ยอมไป เช็ค md5 อะ
ต้องทำอยางงัยอะครับ T_T
|
 |
 |
 |
 |
Date :
2010-05-06 10:34:37 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แน่ใจนะว่า ใน db มันเข้ารหัสให้แล้ว
แล้วไม่เอาโค๊ดมาให้ดู คนตอบก็ งมกันตายเลย 
|
 |
 |
 |
 |
Date :
2010-05-06 11:20:51 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้ code เวลาที่ผม จะบันทึก รหัส อะครับ Code (PHP)
<?php
$member_user = $_POST[member_user];
$member_pass = md5($_POST[member_pass ]);
// add form data processing code here
include('connectdb.php');
$sql="insert into person (id,uid,fname,name,surname,skill,position,member_user
,member_pass,id_card,tel) VALUES ('$id','$uid','$fname','$name','$surname','$skill','$position','$member_user','$member_pass','$id_card','$tel')";
if(mysql_query($sql))
{
echo "<br><BR>";
echo"<CENTER>บันทึกข้อมูลเรียบร้อยแล้ว</CENTER><br>";
echo "<CENTER>กรุณารอสักครู่ ระบบกำลังนำท่านกลับหน้าหลัก</CENTER> <br>";
echo "<meta http-equiv='refresh' content='2 ;url=add_user.php'>";
}
else
{
echo "<br><BR>";
echo"<center>ไม่สามารถบันทึกข้อมูลได้ครับ เนื่องจากมีชื่อ $username นี้อยู่แล้วครับ <b></b> <br>กรุณารอสักครู่</br>";
echo "<br><center>ระบบกำลังนำท่านกลับหน้าหลัก </br>";
echo "<meta http-equiv='refresh' content='3 ;url=add_user.php'>";
}
?>
ส่วนอันนี้หน้า login ครับ
Code (PHP)
<?
include('connectdb.php');
session_start();
$username= $_REQUEST['user'];
$password= $_REQUEST['pass'];
//เช็ค user และ password จาก ฟอร์ม
if ((!empty($username)) And (!empty($password) )) {
$username = trim($_POST['user']);
$password = trim($_POST['pass']);
$sql = "select * from person where member_user='$username' and member_pass ='$password' ";
$dbquery = mysql_query($sql);
$login = mysql_fetch_array($dbquery);
if (!$login) {
echo("<script>alert('No username in database. Please Check your username and password again'); window.location='./';</script>");
exit;
}
if (trim($password) == trim($login['member_pass'])) {
if($login['uid']==9){
//$ip = $REMOTE_ADDR;
// $date=date("d-m-y H:i:s") ;
$_SESSION["regist"]=9;
$_SESSION["sess_fname"]=$login['fname'];
$_SESSION["sess_name"]=$login['name'];
$_SESSION["sess_surname"]=$login['surname'];
$_SESSION["sess_skill"]=$login['skill'];
$_SESSION["sess_position"]=$login['position'];
$_SESSION["sess_thid"]=$login['member_user'];
//$_SESSION["sess_surname"]=$login['surname'];
$_SESSION["sess_uid"]=$login['uid'];
?>
<html>
<title> Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta Http-equiv="refresh" Content="2; Url=admin/index.php">
<style type="text/css">
<!--
.style18 {font-size: 14px}
-->
</style>
<center><br><br>
<br><IMG SRC="images/loading_icon.gif" WIDTH="287" HEIGHT="141" BORDER="0" ALT="">
<br>
<?
echo "<center>คุณกำำลังเข้าสู้ระบบ กรุณารอสักครู่ครับ<br>";
?>
<br><br><br>
</center>
</html>
<?
exit;
}else if($login['uid']==1){
// $ip = $REMOTE_ADDR;
//$date=date("d-m-y H:i:s") ;
$_SESSION["regist"]=1;
$_SESSION["sess_fname"]=$login['fname'];
$_SESSION["sess_name"]=$login['name'];
$_SESSION["sess_surname"]=$login['surname'];
$_SESSION["sess_skill"]=$login['skill'];
$_SESSION["sess_position"]=$login['position'];
$_SESSION["sess_thid"]=$login['member_user'];
//$_SESSION["sess_surname"]=$login['surname'];
$_SESSION["sess_uid"]=$login['uid'];
//echo $_SESSION["sess_name"]." ".$_SESSION["sess_surname"];
//die;
?>
<html>
<title> Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta Http-equiv="refresh" Content="2; Url= employees/index.php">
<center><BR><BR>
<br><IMG SRC="images/loading_icon.gif" WIDTH="287" HEIGHT="141" BORDER="0" ALT="">
<br><BR>
<?
echo "<center>คุณกำลังเข้าสู้ระบบ กรุณารอสักครู่ครับ<br>";
?>
<br><br><br>
</center>
</html>
<?
exit;
}
} else{
?>
<html>
<center>
<script language="javascript">
alert('Please enter the password wrong password again');window.location='./';
</script>
</center>
</html>
<?
exit;
}
}
//จบการเช็ค
?>
<table align="center" width="500" height="140" border="1">
<tr>
<td height="250" align="center" valign="top" bgcolor="#F5F5F5" scope="col">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="220" align="center" valign="top" bgcolor="#FFFFFF">
<br><table width="37%" border="0" align="center" cellpadding="0" cellspacing="0">
</tr>
<tr>
<td scope="col">
<fieldset><legend class="style17">กรุณาลงชื่อเข้าสู่ระบบ</legend>
<table width="76%" border="0" cellspacing="0" cellpadding="0">
</tr>
<td width="330" height="183" scope="col">
<div align="center"><img src="images/icon_login.png" WIDTH="128" HEIGHT="128"></div></td>
<td width="2" bgcolor="#666666" scope="col"></td>
<td width="408" scope="col">
<p align="right"><img src="images/loginlogo.png" WIDTH="221" HEIGHT="56"></p>
<form name="login" method="post" onSubmit="return checklogin()" >
<TABLE WIDTH="274" align="right" >
<TR>
<TD width="100"><div align="right" class="style10">Username :</div></TD>
<TD width="162"><INPUT NAME="user" TYPE="text" size="25" maxlength="13" ></TD>
</TR>
<TR>
<TD width="100"><div align="right" class="style10">Password :</div></TD>
<TD width="162"><INPUT NAME="pass" TYPE="password" size="27" maxlength="13" ></TD>
</TR>
<TR>
<TD colspan="2">
<div align="center">
<INPUT NAME="submit" TYPE="submit" VALUE="เข้าสู่ระบบ" >
</div></TD>
</TR>
</TABLE>
</form>
</td>
</table>
</fieldset>
</tr>
</table>
ส่วนอันนี้เป็นรูปใน ฐานข้อมูลอะครับ

|
 |
 |
 |
 |
Date :
2010-05-06 11:34:52 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$member_pass = md5($_POST[member_pass ]); น่าจะผิดตรงเคาะวรรคนี่แหละ
|
 |
 |
 |
 |
Date :
2010-05-06 11:56:16 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$password= $_REQUEST['pass']; บรรทัดที่ 7
ต้องเข้ารหัสให้ก่อนที่จะเอาไปเทียบสิครับ เพราะใน db เราเข้ารหัสไว้แล้ว
$password= md5($_REQUEST['pass']);
|
 |
 |
 |
 |
Date :
2010-05-06 12:36:22 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ deawx ครับ ผมลอง ทำดูแล้วมันก็ยังไม่ได้เหมือนเดิมอะครับ
ต้องไปแก้ตรงไหนอีกไหมอ่างับ T_T
|
 |
 |
 |
 |
Date :
2010-05-06 13:19:02 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไฟล์แรก
$member_pass = md5($_POST[member_pass ]); น่าจะผิดตรงเคาะวรรค
ลอง echo $_POST[member_pass ] ดูว่ามีค่าหรือเปล่า
ไฟล์สอง
$username= $_REQUEST['user'];
$password= $_REQUEST['pass'];
กับ
$username = trim($_POST['user']);
$password = trim($_POST['pass']);
เลือกเอาสักอย่าง
แล้ว
$sql = "select * from person where member_user='$username' and member_pass ='" . md5($password) . "' ";
|
 |
 |
 |
 |
Date :
2010-05-06 14:08:34 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณพี่ PlaKriM มากนะครับ ตอนนี้ผมทำได้แล้ว ครับ อิอิ
|
 |
 |
 |
 |
Date :
2010-05-07 13:53:57 |
By :
tomsmile |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|