HOME > ASP > ASP Forum > ขอถามเกี่ยวกับการloginครับ คือว่าผมต้องการจะlogin โดยตรวจสอบจาก usrename = ชื่อที่จะล็อคอิน password =รหัสผ่าน type = กำหนดสิทธ์
if(usrename = true And password=true)Then
select type
case a
response.redirect("admin.asp")
case m
response.redirect("employee.asp")
case c
response.redirect("employee.asp")
end select
end if
Code น่าจะประมาณนี้นะครับ ใช่ไหม?
Date :
24 ส.ค. 2550 20:14:14
By :
art
No. 3
Guest
สวัสดีครับ
แบบคุณ art น่าจะถูกต้องแล้วครับ
กระบวนการคือ
1.ตรวจสอบการ input ข้อมูล เช่น ใส่มาหรือไม่ ? ใส่มากี่ตัว จำกัดไหม ?
2.ตรวจสอบกับฐานข้อมูล ข้อมูลที่ระบุมาถูกต้อง
3.เช็ค type ของ user แล้ว redirect เค้าไปยังหน้านั้นๆ
Sql ="select * from login"' where userid='"& request.Form("userid") &"' and password='"& request.Form("password") &"'"
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
If Sql ="select * from login where userid='"& request.Form("userid") &"' and password='"& request.Form("password") &"'" Then
Sql ="select * from login where type = a"
response.redirect("admin.asp")
ElseIf Sql ="select * from login where type = c" Then
response.redirect("customer.asp")
elseif Sql ="select * from login where type = m" Then
response.redirect("employee.asp")
Else response.redirect("login.asp")
end If
Conn.Close
%>
อย่างนี้ใช่รึเปล่านะตามผมที่เข้าใจ
if(NOT RS.EOF)Then 'เช็ตว่าข้อมูลที่ select มามีค่ารึเปล่า ถ้ามีก็ทำต่อ
Type = RS("type") ' ให้เก็บข้อมูล ในฟิวด์ type ที่อยู่ในตารางที่ select มา
Select Type 'เช็ค type ว่าเป็นค่าอะไร
case a
response.redirect("admin.asp")
case c
response.redirect("customer.asp")
case m
response.redirect("employee.asp")
end Select
else
response.redirect("login.asp")
end if
Conn.Close
แล้วที่มัน Redirect กลับไปแต่หน้า login อันนี้ไม่แน่ใจ น่าจะเช็คค่าไม่ถูกต้องตรง if นั้นแหล่ะครับ