how do I redirect a user based on their username a

Results 1 to 2 of 2

Thread: how do I redirect a user based on their username a

  1. #1
    jason Guest

    Default how do I redirect a user based on their username a

    Hi there,<BR><BR>I&#039m new to asp so please forgive my ignorance!<BR><BR>I have set up a login page that requests username and password, and an MS access db that keeps these. I downloaded this script but would like to modify it, so that it redirects the user to their own page, not just a general welcome page.<BR><BR>ie.<BR>User A goes to User A page<BR>User B goes to User B page<BR>User C goes to User C page<BR>etc.<BR><BR>The script is below.<BR><BR>&#060;%<BR><BR> &#039 Create a command object. This object serves to run our queries<BR><BR> Set Cm = Server.CreateObject("ADODB.Command")<BR><BR> &#039 Specify the system DSN path<BR><BR> Cm.ActiveConnection = "LoginDSN"<BR><BR> &#039 Now it&#039s time for the query. We need to check the user information<BR> &#039 against the table tUsers<BR><BR> Cm.CommandText = "SELECT * FROM tUsers WHERE " & _<BR> "UserName=&#039" & Request.Form("UserName") & "&#039 AND " & _<BR> "UserPassword=&#039" & Request.Form("UserPassword") & "&#039 "<BR><BR> &#039 Set the query type. 1 means it is a SQL statement<BR><BR> Cm.CommandType = 1<BR><BR> &#039 Retrieve the results in a recordset object<BR><BR> Set Rs = Cm.Execute<BR><BR> &#039 We now check if the user is valid. If user is valid, the recordset MUST<BR> &#039 haverecord. Otherwise it is empty. If user exists, we set authentication <BR> &#039 status to 1 and send the user to appropriate page, say welcome.asp. <BR> &#039 Else send the user back to login.asp<BR><BR> If Rs.EOF Then<BR>Session("Authenticated") = 0<BR>Response.Redirect ("login.asp")<BR> Else<BR> Session("Authenticated") = 1<BR> Response.Redirect ("welcome.asp")<BR> End If<BR><BR> %&#062;<BR><BR><BR>I realize I need to modify the line<BR><BR>Response.Redirect ("welcome.asp")<BR><BR>so that it knows to send to the particular user&#039s page, but I am unsure how to write this.<BR><BR>Can anybody help please?<BR><BR>Thanks in advance,<BR>jason<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: how do I redirect a user based on their userna

    In the else clause of your if Rs.EOF, try:<BR>----------<BR>Session("Authenticated") = 1<BR>select case Request.Form("UserName") <BR> case "A"<BR> response.redirect "A.asp"<BR> case "B"<BR> response.redirect "B.asp"<BR>end select<BR><BR>-----------<BR>Even easier, though, would be to name each user page the same as the username. Then it would just be:<BR>----------<BR>Session("Authenticated") = 1<BR>response.redirect Request.Form("UserName") & ".asp"<BR>-----------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts