Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing Error and Redirect???

Status
Not open for further replies.

giahan

Programmer
Sep 1, 2000
139
US
Hi all,

I have a login page (name and password) to limit access a couple pages. I am done with the checking and redirect but I get error message if I do something like this:
<%' login.html %>

<form method=&quot;post&quot; action=&quot;validate.asp&quot;>
Name: <input type = &quot;text&quot; name=&quot;name&quot;>
PWord:<input type = &quot;password&quot; name=&quot;pw&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>

<% 'validate.asp %>
If Request.Form(&quot;name&quot;) = &quot;someName&quot;
AND Request.Form(&quot;pw&quot;) = &quot;somePw&quot; Then
Response.Redierct &quot;myasp.asp&quot;
Else
Response.Redirect &quot;mylogin.html&quot;
End If
%>

It works fine like that but if I want to display a message say &quot;Invalid name &amp; password&quot; in the login page.

How do I do that???

Thanks for help






GH
 
try this....

<%'login.asp%>
<form method=&quot;post&quot; action=&quot;validate.asp&quot;>
Name: <input type = &quot;text&quot; name=&quot;name&quot;>
PWord:<input type = &quot;password&quot; name=&quot;pw&quot;>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
</form>

<% 'validate.asp %>
If Request.Form(&quot;name&quot;) = &quot;someName&quot;
AND Request.Form(&quot;pw&quot;) = &quot;somePw&quot; Then
Response.Redirect &quot;myasp.asp&quot;
Else
Response.write (&quot;Invalid Username Or password&quot;)
Response.write (&quot;<a href='mylogin.asp'>Try Again</a>&quot;)
'Response.Redirect &quot;mylogin.html&quot;
End If
%>
 
The thing is I don't want to click on &quot;Try Again&quot; to link to my login.html page.
Anyway, I got the solution for it <% Happy :) %>
Thanks a lot for your prompt response




GH
 
When you link back to your original page, try passing a Query String value back.

<% response.redirect(&quot;mylogin.asp?bad=yes&quot;) %>

Then on your login page you can do this:

<% if request.querystring(&quot;bad&quot;) = &quot;yes&quot; then %>
<p>Incorrect Password. Please try again.</p>
<% end if %>

You can put that wherever you want. If the query value isn't there, it just will skip it. It won't return an error.

Hope that helps.
Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top