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!

How to have users log on...

Status
Not open for further replies.

rhaight

IS-IT--Management
Oct 21, 2002
6
US
How might I go about creating a web page that users have to log on to in order to access the web page. I am using DreamWeaver MX and have noticed they have a log in tool, but I guess I am more curious about a possible database. Do I need one? I just want to set up users with their own password and have them access one page. Do I need a database and if so, what do you recommend?

Thanks.
 
the easiest way would be to use your servers protected directories and just assign a user and pass from there.

Other wise you would need a dbase to hold the user and pass and also then you would need to know what scripting your server supports, ASP, PHP, Cold Fusion. [Hammer]
Nike Failed Slogans -- "Just Don't Do It!"
 
Deecee:

Thanks for the reply, but can you clarify what you mean about using my servers' protected directory to assign a user and pass? How might I go about doing this?

Thanks again.
 
most servers offer protected directories where you log into your server control panel and select directories that you want password protected....then any page accessed in that directory will popup a box that asks for a username and password that you specify in the control panel for your server [Hammer]
Nike Failed Slogans -- "Just Don't Do It!"
 
[tt]On your server behaviors panel,
click the + sign then User Authentication - Log In user

Which then creates form from the fields (username & password) you're using in a table. From there, DW checks if the user exists
else
it kicks them out
enf if


SAMPLE LOG IN FORM W/DW
*************************************************
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/ed.asp&quot; -->
<%
' *** 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;login&quot;))
If MM_valUsername <> &quot;&quot; Then
MM_fldUserAuthorization=&quot;&quot;
MM_redirectLoginSuccess=&quot;search.asp&quot;

'Notice that I pass the valid VALUE false to the page and using this code above my login form, I can display any message needed

ASP code to validate the form if the user is not found.(Instead of redirecting to another page)
<% if request(&quot;valid&quot;) = &quot;false&quot; then
response.write &quot;<font color=red>Login failed. Please try again.</font>&quot;
end if %>

**************************************************
MM_redirectLoginFailed=&quot;default.asp?valid=false&quot;
**************************************************


MM_flag=&quot;ADODB.Recordset&quot;
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_ed_STRING
MM_rsUser.Source = &quot;SELECT REP_Name, Password&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 Representive WHERE REP_Name='&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
If (MM_fldUserAuthorization <> &quot;&quot;) Then
Session(&quot;MM_UserAuthorization&quot;) = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session(&quot;MM_UserAuthorization&quot;) = &quot;&quot;
End If
if CStr(Request.QueryString(&quot;accessdenied&quot;)) <> &quot;&quot; And false Then
MM_redirectLoginSuccess = Request.QueryString(&quot;accessdenied&quot;)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<% if request(&quot;valid&quot;) = &quot;false&quot; then
response.write &quot;<font color=red>Login failed. Please try again.</font>&quot;
end if %>
<table width=&quot;22%&quot; border=&quot;0&quot;>
<tr>
<td width=&quot;16%&quot;>
<p>Login:</p>
<p>Password:</p>
</td>
<td width=&quot;84%&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;<%=MM_LoginAction%>&quot;>
<p>
<input type=&quot;text&quot; STYLE=&quot;font-size:9pt;font-family:eek:cr a extended;color:#336699;cursor:hand&quot; name=&quot;login&quot;>
</p>
<p>
<input type=&quot;text&quot; STYLE=&quot;font-size:9pt;font-family:eek:cr a extended;color:#336699;cursor:hand&quot; name=&quot;password&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</p>
</form>
<script language=&quot;javascript&quot;>
<!--
document.form1.login.focus();
//-->
</script>
</td>
</tr>
<tr>
<td height=&quot;21&quot; width=&quot;16%&quot;> </td>
<td height=&quot;21&quot; width=&quot;84%&quot;> </td>
</tr>
</table>
</body>
</html>
*************************************************



[sup]
T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
Progress2.gif

[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top