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!

ASP Login Script 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can anyone tell me where i can find a good ASP Login Script with a 'Forgotten Password' section included. Most of the ASP sites dont have what i am looking for.

Thanks.

P.S. I am also looking for a ASP Shopping cart script that is quality code with good features and Access 2000 driven.

Hope someone can help!!!
 
Here is the updated script with new user signup:

<%
data_source = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & Server.MapPath(&quot;site.mdb&quot;)
username = Request(&quot;username&quot;)
password = Request(&quot;password&quot;)
try = Request(&quot;try&quot;)
forgot = Request(&quot;forgot&quot;)
newuser = Request(&quot;newuser&quot;)
sendpwtry = Request(&quot;sendpwtry&quot;)
newentry = Request(&quot;newentry&quot;)
newusername = Request(&quot;newusername&quot;)
newpassword = Request(&quot;newpassword&quot;)
newemail = Request(&quot;newemail&quot;)
If newentry = &quot;True&quot; Then
Set rsset = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsset.Open &quot;login&quot;, data_source, 2, 2

rsset.addnew

rsset(&quot;password&quot;) = newpassword
rsset(&quot;username&quot;) = newusername
rsset(&quot;email&quot;) = newemail

rsset.Update
rsset.Movelast
rsset.Close
Set rsset = Nothing

session(&quot;access&quot;)=(&quot;True&quot;)

Response.Redirect &quot;default.asp&quot;

Else
If newuser = &quot;True&quot; Then
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action=&quot;default.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;newentry&quot; value=&quot;True&quot;>
<table>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Username :</font></td>
<td><input type=&quot;text&quot; name=&quot;newusername&quot;></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Password :</font></td>
<td><input type=&quot;password&quot; name=&quot;newpassword&quot;></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>E-mail:</font></td>
<td><input type=&quot;text&quot; name=&quot;newemail&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;right&quot;><input type=&quot;submit&quot; value=&quot;Signup&quot;></td>
</tr>
</table>
</form>
</body>
</html>
<%
Else
If sendpwtry = &quot;True&quot; Then
Set rsp = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsp.Open &quot;select * from login where ( username = '&quot; & USERNAME & &quot;' )&quot;, data_source
If rsp.EOF And rsp.BOF Then
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action>
<input type=&quot;hidden&quot; name=&quot;sendpwtry&quot; value=&quot;True&quot;>
<table>
<tr>
<td><img alt=&quot;&quot;&quot;&quot; src=&quot;&quot;../img/spacer.gif&quot;&quot; height=&quot;&quot;10&quot;&quot; width=&quot;&quot;1&quot;&quot;></td>
</tr>
<tr>
<td colspan=&quot;&quot;2&quot;&quot;><font face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot; size=&quot;&quot;2&quot;&quot;>That username does not exist in the database</font></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Username :</font></td>
<td><input type=&quot;text&quot; name=&quot;username&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;right&quot;><input type=&quot;submit&quot; value=&quot;Request Password&quot;></td>
</tr>
</table>
</form>
</body>
</html>
<%
rsp.Close
Set rsp = Nothing
Else
%>
<html>
<head>
<title>
</title>
</head>
<body>
<table>
<tr>
<%
name = &quot;Your-Site admin&quot;
senderEmail = &quot;admin@your-site.com&quot;
subject = &quot;You password is...&quot;
recipient = rsp(&quot;email&quot;)
body = &quot;... Hello &quot; & rsp(&quot;username&quot;) & &quot; your password is : ' &quot; & rsp(&quot;password&quot;) & &quot; '&quot;


set msg = Server.CreateOBject( &quot;JMail.Message&quot; )

msg.Logging = true
msg.silent = true


msg.From = senderEmail
msg.FromName = name

msg.AddRecipient recipient

msg.body = body

If not msg.Send(&quot;mail.your-server.co.uk&quot; ) Then
Response.Write &quot;<td><font face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot; size=&quot;&quot;2&quot;&quot;>&quot; & msg.log & &quot;</font></td>&quot;
Else
Response.Write &quot;<td><font face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot; size=&quot;&quot;2&quot;&quot;>Your password has been e-mailed to : &quot; & rsp(&quot;email&quot;) & &quot;</font></td>&quot;
End If

rsp.Close
Set rsp = Nothing
%>
</tr>
</table>
</form>
</body>
</html>
<%
End If
Else
If forgot = &quot;True&quot; Then
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action>
<input type=&quot;hidden&quot; name=&quot;sendpwtry&quot; value=&quot;True&quot;>
<table>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Username :</font></td>
<td><input type=&quot;text&quot; name=&quot;username&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;right&quot;><input type=&quot;submit&quot; value=&quot;Request Password&quot;></td>
</tr>
</table>
</form>
</body>
</html>
<%
Else
If try = &quot;True&quot; Then
If session(&quot;access&quot;) = &quot;True&quot; Then
Response.Write &quot;&quot;
Else
Set rsp = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsp.Open &quot;select * from login where ( username = '&quot; & USERNAME & &quot;' ) and ( password = '&quot; & PASSWORD & &quot;')&quot;, data_source
If rsp.EOF And rsp.BOF Then
rsp.Close
Set rsp = Nothing
eror = &quot;<tr><td><img alt=&quot;&quot;&quot;&quot; src=&quot;&quot;../img/spacer.gif&quot;&quot; height=&quot;&quot;10&quot;&quot; width=&quot;&quot;1&quot;&quot;></td></tr><tr><td colspan=&quot;&quot;2&quot;&quot;><font face=&quot;&quot;Verdana, Arial, Helvetica, sans-serif&quot;&quot; size=&quot;&quot;2&quot;&quot;><h1>Login Incorrect</h1>Please retype your <strong>username</strong> and <strong>password</strong></font></td></tr>&quot;
Else
pword = rsp(&quot;password&quot;)
uname = rsp(&quot;username&quot;)
rsp.Close
Set rsp = Nothing
If pword = password And uname = username Then
session(&quot;access&quot;)=(&quot;True&quot;)
End If
End If
End If
End If
If Not session(&quot;access&quot;) = &quot;True&quot; Then
%>
<html>
<head>
<title>
</title>
</head>
<body>
<form action=&quot;default.asp&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;try&quot; value=&quot;True&quot;>
<table>
<tr>
<td colspan=&quot;2&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Enter you login information below.</font></td>
</tr>
<% =eror %>
<tr>
<td><img alt=&quot;&quot; src=&quot;../img/spacer.gif&quot; height=&quot;10&quot; width=&quot;1&quot;></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Username :</font></td>
<td><input type=&quot;text&quot; name=&quot;username&quot;></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Password :</font></td>
<td><input type=&quot;password&quot; name=&quot;password&quot;></td>
</tr>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;><a href=&quot;default.asp?forgot=True&quot;>Forgot password ?</a></font></td>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;><a href=&quot;default.asp?newuser=True&quot;>New user ?</a></font></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;right&quot;><input type=&quot;submit&quot; value=&quot;Login&quot;></td>
</tr>
</table>
</form>
</body>
</html>
<%
Else
%>
<html>
<head>
<title>
</title>
</head>
<body>
<table>
<tr>
<td><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>You are now logged in.</font></td>
</tr>
</table>
</body>
</html>
<%
End If
End If
End If
End If
End If
%> Regards

Big Dave


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Here's a good and simple construct I did which embeds the USERNAME/PASSWORD combination within the coding of the page.


The benefits herein are that:

(1) You don't have to mess with the overhead of a database connection and worry about persistence of variables or session data.
(2) You can reference a simple SSI include file that will password-protect any or all files within a directory...so they bounce the user back to the login page if he/she tries to access protected pages directly via typing the URL.

It's not a hardcore, e-commerce level solution, but it works for simple matters.

Jason
jason@kuam.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top