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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Authentication - check username question

Status
Not open for further replies.

bluranj

Programmer
Mar 11, 2002
239
US
server behaviors >> user authentication >> check names Ranjan
- A Dreamweaver Community
Join today for your answers in web design
 
[tt]
bluranj's suggestion is the default way dreamweaver handles this and a good one.

Here's how I handle it:

<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables(&quot;URL&quot;)
If Request.QueryString<>&quot;&quot; Then MM_LoginAction = MM_LoginAction + &quot;?&quot; + Request.QueryString
MM_valUsername=CStr(Request.Form(&quot;username&quot;))
If MM_valUsername <> &quot;&quot; Then
MM_fldUserAuthorization=&quot;&quot;
MM_redirectLoginSuccess=&quot;default.asp&quot;
MM_redirectLoginFailed=&quot;login.asp?valid=false&quot;
MM_flag=&quot;ADODB.Recordset&quot;
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_MYDSN_STRING
MM_rsUser.Source = &quot;SELECT *&quot;
If MM_fldUserAuthorization <> &quot;&quot; Then MM_rsUser.Source = MM_rsUser.Source & &quot;,&quot; & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & &quot; FROM dbo.MyTable WHERE username='&quot; & MM_valUsername &&quot;' AND password='&quot; & CStr(Request.Form(&quot;password&quot;)) & &quot;'&quot;
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session(&quot;MM_Username&quot;) = MM_valUsername...
etc, etc, etc...
%>


Then on your just below your <form> tag do this:
<% if request(&quot;valid&quot;) = &quot;false&quot; then
response.write &quot;<font color=red>
Login failed. Please try again.</font>&quot;
end if %>
* * * * * * * * * * *
<%=Tony%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top