simon315
12-24-2003, 11:56 PM
Hi. I've got a question that I cannot seem to make work. I've got a page that when a user clikcs on a link it popups a page that allows them to login to the site. Once they click on submit, the username and password are then authenticated and based on which username they used, they are then directed to a specific page (which could be one page of many different choices). My problem is that once they user is properly authenticated I need two things to happen:
1. the user must be redirected to their specific page, but the page they clicked on to get the login pop-up is the page that needs to be redirected, not the login page.
2. the login page needs to close once they have been authenticated and the proper page has been redirected.
I've tried to use Javascript mixed in within the ASP to make this work, but I can only get the window to close on it's own. I can't figure out how to get the original page to be redirected. Can someone please help? Here is the code I'm working with:
<!--#include file="login_conn.asp"-->
<%
User = Request.Form("username")
Pass = Request.Form("password")
'Create the RecordSet
Set RS = Server.createObject("ADODB.recordset")
SQL = "Select *From clients WHERE User_Name in('"&User&"') and User_Password in('"&Pass&"')"
RS.Open SQL, objConn
'Check to see if username and password are in database, if not redirect them
If RS.EOF Then
Session("LoggedIn") = 0
Session("UserID") = 0
Response.Redirect("../extranet3/login_failure.htm")
Else
Area = RS("User_Client_Area")
Session("LoggedIn") = Area
Session("UserID") = RS("User_ID")
'Kill the RecordSet
RS.Close
'If user is found, update the LAST_LOGIN field
Set RS = Nothing
SQL = "Update clients Set User_Last_Login = Now() WHERE User_Name = '"&User&"' AND User_Password = '"&Pass&"'"
ObjConn.Execute(SQL)
'Kill the Database Connection
ObjConn.Close
Set ObjConn = nothing
'Redirect user after authentication
If Area = 1 Then Page = "client1/index.asp"
If Area = 2 Then Page = "xxx/index.asp"
Response.redirect(Page)
Response.Write("<SCRIPT>window.close()</SCRIPT>")
End if
%>
Thanks in advance!
Simon315
1. the user must be redirected to their specific page, but the page they clicked on to get the login pop-up is the page that needs to be redirected, not the login page.
2. the login page needs to close once they have been authenticated and the proper page has been redirected.
I've tried to use Javascript mixed in within the ASP to make this work, but I can only get the window to close on it's own. I can't figure out how to get the original page to be redirected. Can someone please help? Here is the code I'm working with:
<!--#include file="login_conn.asp"-->
<%
User = Request.Form("username")
Pass = Request.Form("password")
'Create the RecordSet
Set RS = Server.createObject("ADODB.recordset")
SQL = "Select *From clients WHERE User_Name in('"&User&"') and User_Password in('"&Pass&"')"
RS.Open SQL, objConn
'Check to see if username and password are in database, if not redirect them
If RS.EOF Then
Session("LoggedIn") = 0
Session("UserID") = 0
Response.Redirect("../extranet3/login_failure.htm")
Else
Area = RS("User_Client_Area")
Session("LoggedIn") = Area
Session("UserID") = RS("User_ID")
'Kill the RecordSet
RS.Close
'If user is found, update the LAST_LOGIN field
Set RS = Nothing
SQL = "Update clients Set User_Last_Login = Now() WHERE User_Name = '"&User&"' AND User_Password = '"&Pass&"'"
ObjConn.Execute(SQL)
'Kill the Database Connection
ObjConn.Close
Set ObjConn = nothing
'Redirect user after authentication
If Area = 1 Then Page = "client1/index.asp"
If Area = 2 Then Page = "xxx/index.asp"
Response.redirect(Page)
Response.Write("<SCRIPT>window.close()</SCRIPT>")
End if
%>
Thanks in advance!
Simon315