ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingช่วยดู code login แบบ session ให้หน่อยค่ะ ไม่รู้ว่าผิดเพราะอะไร loginไม่ได้
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ช่วยดู code login แบบ session ให้หน่อยค่ะ ไม่รู้ว่าผิดเพราะอะไร loginไม่ได้  (อ่าน 688 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
jailaline
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 27



ดูรายละเอียด
« เมื่อ: 20 พฤษภาคม 2009, 19:02:51 »

<?php
session_start();
if (!session_is_registered("username")) {
   session_register("username");
if (!session_is_registered("password"))
    session_register("password");
 }
$con = mysql_connect("localhost","root","1234");
$username_log=$_POST["username"];
$passname_log=$_POST["password"];

if (!$con)
  {
           die('Could not connect: ' . mysql_error());
  }
 else {
         print"connect database";
           echo "<br />";
mysql_select_db("sendfile", $con);
$sql_command = " SELECT  * FROM user_student  where username = '$username_log' and password='$password_log' ";
$result = mysql_query($sql_command);
$num_rows = mysql_num_rows($result);

 if ($num_rows ==1 ) {
    header("location: main_student.php");
       echo "password your  ok!!!!!";
       new_pop_window();
 }
  else {
  header("location: notlogin.php");
    echo "password not ok!!!";
  }   //   end   else
  }

   mysql_close($con);
   session_unregister("username");
   session_unregister("password");
   ?>
บันทึกการเข้า
Kobsoft
Verified Seller
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 255
ออฟไลน์ ออฟไลน์

กระทู้: 2,574



ดูรายละเอียด
« ตอบ #1 เมื่อ: 20 พฤษภาคม 2009, 19:41:01 »

โค๊ด:
 :-[ สดนะคับมั่วๆ เอาถ้าเป็นผมเขียนง่ายๆ

<?
session_start();
session_register("username");
include_once("Connect File Here");
$sql = mysql_query(" SELECT * FROM user_student WHERE (username='$_????[username_log]' && password='$_????[password_log]') LIMIT 0, 1", Connect Var );
$F = mysql_fetch_array($sql);
$numrow = mysql_num_rows($sql);

if ($numrow>0){
   $_SESSION["username"] = $F[username]; // or = strtolower($F[username]);
   new_pop_window();
   $reURL = "main_student.php";
   header("HTTP/1.1 301 Moved Permanently");
   header("Location: $reURL");
}
else{
   $reURL = "notlogin.php";
   header("HTTP/1.1 301 Moved Permanently");
   header("Location: $reURL");
}
mysql_close(????);
?>

บันทึกการเข้า
jailaline
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 27



ดูรายละเอียด
« ตอบ #2 เมื่อ: 21 พฤษภาคม 2009, 11:38:38 »

ขอบคุณมากๆนะค่ะ Kiss คุณ kobsoft
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์