PDA

View Full Version : Redirect than Write?



TheShadow
05-23-2005, 03:08 AM
<%
username = Session("username")
if ("" = username) Then
Response.redirect "login.asp"
response.Write("Sorry, you are not logged in.")
response.End
End if
%>

How do i write that Sorry, you are not logged in ... to the login.asp?

mwinter
05-23-2005, 12:05 PM
<%
username = Session("username")
if ("" = username) Then
Response.redirect "login.asp"
response.Write("Sorry, you are not logged in.")
response.End
End if
%>

How do i write that Sorry, you are not logged in ... to the login.asp?I don't 'do' ASP so I can't provide specifics.

I assume that login.asp is used to receive input from the user. If so, the login.asp should be checking the input itself. That is, it should submit the form to itself.

If the data is invalid, you can serve up a slightly different document with an error message inserted. If valid, login.asp can redirect to a member page, or wherever is most appropriate.

Time delayed redirection, like that used in this forum when logging in, should be avoided in my opinion, mainly because that type of redirection is non-standard, generally frowned upon, and can be disabled (in other words, it's not reliable).

Mike

ringpull
05-28-2005, 08:56 AM
Hi Shadow,

You're best bet is to querystring the response.redirect, for example:


<%
username = Session("username")
if ("" = username) Then
Response.redirect "login.asp?status=notloggedin"
response.End
End if
%>


Then, in the code of you're login.asp page, where you want the message to appear, put an If statement:



<%
if request.querystring("status") = "notloggedin" then response.write("Sorry, you are not logged in.")
%>


I hope this works :)

Carl.