 |
|
มีปัญหาที่หน้า login ค่ะ รบกวนด้วยค่ะ ปัญหาคือ มันไม่ redirect ให้ค่ะ แล้วก็ไม่ยอมโชว์คำเตือนเมื่อพิมพ์ id กับ pass ผิด |
|
 |
|
|
 |
 |
|
ปัญหาคือ มันไม่ redirect ให้ค่ะ แล้วก็ไม่ยอมโชว์คำเตือนเมื่อพิมพ์ id กับ pass ผิด
พอดีว่ามือใหม่ค่ะ ช่วยทีนะคะ
พยายามหาในบทเรียน asp แล้วก็ยังทำไม่ได้ค่ะ T T
server 2000
asp + access97
ขอบคุณค่ะ
ปอลิง S_Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database.mdb")
Code (ASP)
<!--#INCLUDE FILE="lib/inc/Main.inc"-->
<%
strThisPage = "admin_login.asp"
'Get Form value
strUsername =Request.Form("username")
strPassword =Request.Form("password")
Session(S_Username) = strUsername
If strUsername <> "" Then
conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("database.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Mode = adModeReadWrite
Conn.Open S_Connection
'Open Recordset
SQLStr1 = "select * from emp_table where " & _
" username='" & Request("username") & "'"
Set rs1 = Conn.Execute(sQLStr1)
if rs1.EOF then
Response.Write "<script>alert('ท่านยังไม่เคยสมัครเป็นสมาชิก');"
Response.Write "</script>"
else
SQLStr = "select * from emp_table where " & _
" username='" & Request("username") & "'" & _
" and password='" & Request("password") & "'"
Set rs = Conn.Execute(sQLStr)
If Not RS.EOF Then
blnPass = True
Session("darkagent") = true
Set Conn1 = Server.CreateObject("ADODB.Connection")
Conn1.Mode = adModeReadWrite
Conn1.Open S_connection
strSQL1 = "SELECT * FROM query3 where emp_no = '" & rs("username") & "'"
Set RS1 = Server.CreateObject("ADODB.Recordset")
RS1.Open strSQL1, Conn1, adOpenKeySet, adLockOptimistic, adCmdText
session("emp_no") = rs1("emp_no")
session("newcode") = rs1("newcode")
Session("title_name") = RS1("title_name")
session("emp_name") = rs1("emp_name")
session("emp_position") = rs1("emp_position")
Response.Redirect "administrator.asp"
Else
'ไม่พบสมาชิก
blnPass = False
Session(S_Login) = ""
strErrorMessage = "หมายเลขประจำตัวพนักงาน หรือ รหัสผ่านไม่ถูกต้อง"
end if
If blnPass Then
Response.Redirect strNextURL
rs.Close
rs1.Close
conn.Close
conn1.Close
End If
End If
End If
%>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-874">
<title>LOG IN</title>
<LINK REL="stylesheet" HREF="Lib/css/General.css">
<script language="JavaScript" src="Lib/js/form.js">
</script>
<style>
body{
scrollbar-3dlight-color: #ffffff;
scrollbar-arrow-color: #0000ff;
scrollbar-track-color: #ffffff;
scrollbar-darkshadow-color: #ffffff;
scrollbar-face-color: #ffffff;
scrollbar-highlight-color: #1e90ff;
scrollbar-shadow-color: #1e90ff;
}
</style>
</head>
<body>
<%If strErrorMessage <> "" Then%>
<font size="2">
<br></font><div class="ErrorText" align="center"><font size="2"><%=strErrorMessage%></font></div>
<font size="2"><br>
<%End If%> </font>
<FORM METHOD="post" ACTION="<%=strThisPage%>" id=form1 name=form1>
<div align="center">
<table width="564" height="350" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="125" height="178"><span class="style2"></span></td>
<td width="254"><span class="style2"></span></td>
<td width="40"><span class="style2"></span></td>
<td width="200"> </td>
<td width="37"> </td>
</tr>
<tr>
<td height="23"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td height="25"><div align="left"></div></td>
<td bgcolor="#FFFFCC"><div align="right" class="style7 style2 style8">
<b>
<font face="Microsoft Sans Serif" size="2">หมายเลขประจำตัวพนักงาน :</font>
</b> </div></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"><font face="Microsoft Sans Serif"><input name="username" style="text-align: center" size="20" maxlength="10"/></font></td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td height="19"> </td>
<td bgcolor="#FFFFCC"><span class="style8"></span></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td height="25"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"><div align="right" class="style7 style2 style8">
<b>
<font face="Microsoft Sans Serif" size="2">รหัสผ่าน : </font> </b> </div></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"><font face="Microsoft Sans Serif"><input name="password" type="password" style="text-align: center" size="20" maxlength="20"/></font></td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td height="19"> </td>
<td bgcolor="#FFFFCC" colspan="4" height="19"> </td>
</TR>
<tr>
<td height="61"> </td>
<td bgcolor="#FFFFCC" colspan="4" height="61">
<p align="center"><font face="MS Sans Serif">
<INPUT TYPE="button" NAME="Button" VALUE=" Log in " onClick="ValidateForm(this.form, this.form.Login.value, 'หมายเลขประจำตัวพนักงาน', true, 'Text',this.form.password.value, 'รหัสผ่าน', true, 'Text');" style="font-weight: 700"></font></td>
</TR>
<tr>
<td height="61"> </td>
<td bgcolor="#FFFFCC" colspan="4" height="61">
<p align="center">
<b>
<font size="2" face="Microsoft Sans Serif" color="#FF0000"><span class="style5">
<font size="2" face="Microsoft Sans Serif">พนักงานเข้าใหม่ กรุณาติดต่อ 8350</font></span></font></b></p>
<font size="2">
</font></td>
</TR>
</TABLE>
</div>
</FORM><DIV ALIGN="center"> </DIV>
</body>
</html>
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-07-20 09:19:04 |
By :
embell |
View :
1475 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หรือว่ามันจะผิดทั้งหมด - -
|
 |
 |
 |
 |
Date :
2010-07-20 14:59:07 |
By :
embell |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอไปเขียน oop แล้วกลับมาดูแบบนี้แล้วไม่เกิดอารมณ์เลยครับ 
ลองเขียนโฟวแล้วลองไล่ดูครับ ปัญหามันน่าจะเกิดจากลอจิกมากกว่าโค้ด
|
 |
 |
 |
 |
Date :
2010-07-20 15:12:30 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค่ะ ขอบคุณค่ะ T T
|
 |
 |
 |
 |
Date :
2010-07-20 15:22:32 |
By :
embell |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้ Response.End() ในการ Debug ว่าค่าหรือ flow มันวิ่งผ่านตรงไหนบ้างครับ
|
 |
 |
 |
 |
Date :
2010-07-21 06:29:53 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค่ะ ตอนนี้ทำผ่าน แล้วค่ะ ขอบคุณพี่ๆมากค่ะ ^3^
จะขอลง code ที่รันผ่านไว้นะคะ เผื่อคนที่กำลังมีปัญหาเหมือนกันกำลัง search หาอยู่
Code (ASP)
<!--#INCLUDE FILE="lib/inc/Main.inc"-->
<%
strThisPage = "admin_login.asp"
'Get Form value
strUsername =Request.Form("username")
strPassword =Request.Form("password")
Session(S_Username) = strUsername
If strUsername <> "" Then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Mode = adModeReadWrite
Conn.open S_connection
'Open Recordset
SQLStr1 = "select * from emp_table where " & _
" username='" & Request("username") & "'"
Set rs1 = Conn.Execute(sQLStr1)
if rs1.EOF then
Response.Write "<script>alert('ท่านยังไม่เคยสมัครเป็นสมาชิก');"
Response.Write "</script>"
else
SQLStr = "select * from emp_table where " & _
" username='" & Request("username") & "'" & _
" and password='" & Request("password") & "'"
Set rs = Conn.Execute(sQLStr)
If Not RS.EOF Then
blnPass = True
Session("darkagent") = true
Set Conn1 = Server.CreateObject("ADODB.Connection")
Conn1.Mode = adModeReadWrite
Conn1.Open S_connection
strSQL1 = "SELECT * FROM query3 where emp_no = '" & rs("username") & "'"
Set RS1 = Server.CreateObject("ADODB.Recordset")
RS1.Open strSQL1, Conn1, adOpenKeySet, adLockOptimistic, adCmdText
session("emp_no") = rs1("emp_no")
session("newcode") = rs1("newcode")
Session("title_name") = rs1("title_name")
session("emp_name") = rs1("emp_name")
session("dept_name") = rs1("dept_name")
session("emp_position") = rs1("emp_position")
Response.Redirect "administrator.asp"
Else
'ไม่พบสมาชิก
blnPass = False
Session(S_username) = ""
strErrorMessage = "รหัสประจำตัวพนักงาน หรือ รหัสผ่านไม่ถูกต้อง"
End If
If blnPass Then
Response.Redirect strNextURL
rs.Close
rs1.Close
conn.Close
conn1.Close
End If
end if
End If
%>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-874">
<title>LOG IN</title>
<LINK REL="stylesheet" HREF="Lib/css/General.css">
<script language="JavaScript" src="Lib/js/form.js">
</script>
<style>
body{
scrollbar-3dlight-color: #ffffff;
scrollbar-arrow-color: #0000ff;
scrollbar-track-color: #ffffff;
scrollbar-darkshadow-color: #ffffff;
scrollbar-face-color: #ffffff;
scrollbar-highlight-color: #1e90ff;
scrollbar-shadow-color: #1e90ff;
}
</style>
</head>
<body>
<%If strErrorMessage <> "" Then%>
<font size="2">
<br></font><div class="ErrorText" align="center"><font size="2"><%=strErrorMessage%></font></div>
<font size="2"><br>
<%End If%> </font>
<FORM METHOD="post" ACTION="<%=strThisPage%>" id=form1 name=form1>
<div align="center">
<table width="508" height="350" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="256"> <p> </p>
<p> </td>
<td width="24"><span class="style2"></span></td>
<td width="128"> </td>
<td width="99"> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"><span class="style2"></span></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><div align="right" class="style7 style2 style8">
<b>
<font face="Microsoft Sans Serif" size="2">หมายเลขประจำตัวพนักงาน :</font>
</b> </div></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"><font face="Microsoft Sans Serif"><input name="username" style="text-align: center" size="20" maxlength="10"/></font></td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><span class="style8"></span></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><div align="right" class="style7 style2 style8">
<b>
<font face="Microsoft Sans Serif" size="2">รหัสผ่าน : </font> </b> </div></td>
<td bgcolor="#FFFFCC"> </td>
<td bgcolor="#FFFFCC"><font face="Microsoft Sans Serif"><input name="password" type="password" style="text-align: center" size="20" maxlength="20"/></font></td>
<td bgcolor="#FFFFCC"> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC" colspan="4" height="19"> </td>
</TR>
<tr>
<td bgcolor="#FFFFCC" colspan="4" height="61">
<p align="center"><font face="MS Sans Serif">
<INPUT TYPE="button" NAME="Button" VALUE=" Log in " onClick="ValidateForm(this.form, this.form.username.value, 'หมายเลขประจำตัวพนักงาน', true, 'Text',this.form.password.value, 'รหัสผ่าน', true, 'Text');" style="font-weight: 700"></font></td>
</TR>
<tr>
<td colspan="4" height="61">
<p align="center">
</p>
<p align="center">
<b>
<font size="2" face="Microsoft Sans Serif" color="#FF0000">
<span class="style5">
<font size="2" face="Microsoft Sans Serif">พนักงานเข้าใหม่ กรุณาติดต่อ 8350</font></span></font></b></p>
<p align="center">
<a href="default.html">กลับหน้าหลัก</a></p>
<p align="center">
</p>
</td>
</TR>
</TABLE>
</div>
</FORM><DIV ALIGN="center"> </DIV>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-07-21 09:58:16 |
By :
embell |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|