Dreamweaver Forms and dynamic text?
I have a login page on my website where a username and password field have to filled in correctly in order to be redirected to a secure page. At the moment if the username or password is filled in incorectly they are redirected to the same login page wher they have to login again.
My question is, if the username or password is incorrect, how do I get a text field to come up automatically saying thay either their username or password have been filled in incorrectly as I have seen on so many sites..Thanks
Comments
Displaying Incorrect Login
Hi Albert, hopefully this will help you out.
What you need to do is create your basic LOGIN SB and then modify the code very slightly. What your going to do is remove the line of code that redirects the user after the click your button. Instead, you want to say if their username is wrong, I want to display a message.
Locate this line: Response.Redirect(MM_redirectLoginFailed)
1. Comment it out by putting a ' right before it.
2. Add this line after the above line: Session("loginfailed") = Session("MM_Username")
Next you will want to locate where you have created your text fields and what not for your login form and insert the code where you want the incorrect login message to appear.
1. Add this code:
<%
If Request.Form("submit") = "LOGIN" Then
If Session("loginfailed") = "" Then
Response.Write("Please try again. Your username or password was incorrect.")
End If
End If
%>
This is probably not the most effecient way to do this but it has worked for me without ever any problems.
Very simple.
First, you need to make the difference between your loggued users and the others. A condition set to TRUE can create for you a session variable. for exemple :
if (login == "successfull") Session("loggued")= true
When you come to your loggin page, call that Session variable.
if (Session("loggued") != true) Response.Write("Your loggin informations are incorrect. Please, try again.")
Redirect with query
If you set your failed login as (MM_redirectLoginFailed="login.asp?err=1") and on your login page set up a conditional display something like
<% If Request.QueryString("err") = "1" Then %>
You have not logged in successfully. Please try again
<% End If %>
Hope this helps
You must me logged in to write a comment.