Home | Advertising Info1 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 13, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Scripting
 PowerASP Code Help Area : Classic ASP - Scripting
Subject Topic: login example - I need help Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
theano
Newbie
Newbie


Joined: July/22/2004
Location: Greece
Online Status: Offline
Posts: 1
Posted: July/22/2004 at 11:40am | IP Logged Quote theano

Hello , I have this code , is the register page for a login example:

<%

'Save entered username and password

Username = Request.Form("txtUsername")

Password = Request.Form("txtPassword")

Password2 = Request.Form("txtPassword2")

Firstname = Request.Form("txtFirstname")

Lastname = Request.Form("txtLastname")

AEM = Request.Form("txtAEM")

EmailAddress=Request.Form("txtEmailAddress")

'check if password not match with password2

if Password <> Password2 Then

Response.Redirect("login.asp?login=pass2failed")

end if

'Check if username and password are entered

if Username = "" then Response.redirect("login.asp?login=createnamefailed")

if Password = "" then Response.Redirect("login.asp?login=createpassfailed")

if FirstName = "" then Response.Redirect("login.asp?login=createfnamefailed")

if LastName = "" then Response.Redirect("login.asp?login=createlnamefailed")

if AEM = "" then Response.Redirect("login.asp?login=createaemfailed")

'if EmailAddress = "" then Response.Redirect("login.asp?login=creatednew")

'Build connection

set conn = server.CreateObject ("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("users.mdb")

set rs = server.CreateObject ("ADODB.Recordset")

'Open all records

rs.Open "SELECT * FROM userlist", conn, 3, 3

'Check if username doesn't already exist

do while not rs.EOF

if rs("username")=Username then

set rs=nothing

set conn=nothing

Response.Redirect("login.asp?login=createnamefailed")

end if

rs.MoveNext

loop

'Add a record

rs.AddNew

'Put username and password in record

rs("username")=Username

rs("password")=Password

rs("firstname")=Firstname

rs("lastname")=Lastname

rs("aem")=AEM

'rs("emailaddress")= EmailAddress

'Save record

rs.Update

set rs=nothing

set conn=nothing

Response.Redirect("login.asp?login=creatednew")

%>

I have created two tables in a database, the first one called "userlist" and the second "students" . I want to be able to register only users whose AEM (personal number of students) from the student table is the same with the AEM who write when they do create of a new login.

if anyone can help me , please sent all the new code for the register page.

thank you

Back to Top View theano's Profile Search for other posts by theano
 
cwilliams
Admin Group
Admin Group
Avatar

Joined: April/26/2004
Location: United States
Online Status: Offline
Posts: 137
Posted: July/23/2004 at 12:07pm | IP Logged Quote cwilliams

I'd thingk about buying something like this if I were you. www.aspprotect.com "yes I sell it but it will save you a lot of time and you'll learn alot" You'd also need to custimize it a bit for your specific needs.

Back to your code...

Your doing some fairly bad things in the code above. Too many things to comment on really as I just dont have the time.

The looping thru records looking for the username being used is especially scary. That should a simple SQL statement with a specific query for that user. Looping thu records like that is a total waste of resources and could get real ugly if you had a lot of users..

Also, The errors you are sending back arent going to repopulate the fields people filled in and that make it a pain for anyone registering.

Take Care..



Edited by cwilliams on July/23/2004 at 12:11pm


__________________


Chris Williams
http://www.PowerASP.com
Back to Top View cwilliams's Profile Search for other posts by cwilliams
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

vbscript active server pages ASP vbscript SQL database informix oracle SQL Server Perl CGI Delphi PHP source code code sample samples program CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com