473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

stopping users registering with the same username?

Hi, i've got a asp page to register a user and check that the username has
not been previously registered, heres the code i have ... that doesnt work
<SCRIPT LANGUAGE=vbscript RUNAT=server>
'Adds a record to the table

Dim SQL 'A variable for the SQL statement
Dim ObjConn 'A connection varaible
Dim ObjRS
Set ObjConn = Server.CreateObject("ADODB.Connection")
Set ObjRS = Server.CreateObject("ADODB.Recordset")


rsSQL = "SELECT * FROM tblUsers WHERE strUser='" & Request.Form("strUser") &
"' "

SQL = "INSERT INTO tblUsers "
SQL = SQL & "(strUser, strPwd, strEmail) "
SQL = SQL & "VALUES ('"& Request.Form("strUser") & "', '" &
Request.Form("strPwd") & "','" & Request.Form("strEmail") & "')"

ObjRS.Open rsSQL, "DSN=Project"

If ObjRS.RecordCount > 1 Then

Response.Redirect ("retry.html")

Else
ObjConn.Open "DSN=project"
ObjConn.Execute SQL

End If

ObjConn.Close
Set ObjConn = nothing

Response.Redirect("ok.html")

</script>

i am going the right way about it?
if so where have i gone wrong?
if not could someone please point me in the right direction
any help is appeciated
Regards
Jul 19 '05 #1
2 1774
Dim SQL 'A variable for the SQL statement
Dim ObjConn 'A connection varaible
Dim ObjRS

Set ObjConn = Server.CreateObject("ADODB.Connection")
rsSQL = "SELECT * FROM tblUsers WHERE strUser='" & Request.Form("strUser") &
"' "
ObjRS = ObjConn.execute(sql) ' check for existing user
if ObjRS.EOF = True then ' it's OK its a new user so add them
SQL = "INSERT blah blah
ObjConn.execute(SQL)
else ' reject that user
response.redirect "retry.html"
end if

I'd do it like this
just my 2p worth

"lawtonl" <l.******@totalise.co.uk> wrote in message
news:3f**********************@news.ukonline.co.uk. ..
Hi, i've got a asp page to register a user and check that the username has
not been previously registered, heres the code i have ... that doesnt work
<SCRIPT LANGUAGE=vbscript RUNAT=server>
'Adds a record to the table

Dim SQL 'A variable for the SQL statement
Dim ObjConn 'A connection varaible
Dim ObjRS
Set ObjConn = Server.CreateObject("ADODB.Connection")
Set ObjRS = Server.CreateObject("ADODB.Recordset")


rsSQL = "SELECT * FROM tblUsers WHERE strUser='" & Request.Form("strUser") & "' "

SQL = "INSERT INTO tblUsers "
SQL = SQL & "(strUser, strPwd, strEmail) "
SQL = SQL & "VALUES ('"& Request.Form("strUser") & "', '" &
Request.Form("strPwd") & "','" & Request.Form("strEmail") & "')"

ObjRS.Open rsSQL, "DSN=Project"

If ObjRS.RecordCount > 1 Then

Response.Redirect ("retry.html")

Else
ObjConn.Open "DSN=project"
ObjConn.Execute SQL

End If

ObjConn.Close
Set ObjConn = nothing

Response.Redirect("ok.html")

</script>

i am going the right way about it?
if so where have i gone wrong?
if not could someone please point me in the right direction
any help is appeciated
Regards

Jul 19 '05 #2
> plus why not specify the field rather than use the * in the Select, those
*
can bite you know (http://www.aspfaq.com/show.asp?id=2188)
or just use count(*)
"only me" <on*****@hotmail.com> wrote in message
news:Xi******************@newsfep4-glfd.server.ntli.net... correction
rsSQL = "SELECT * FROM tblUsers WHERE strUser='" & Request.Form("strUser")
&
"' "
ObjRS = ObjConn.execute(sql) ' check for existing user
should have been
SQL = "SELECT * FROM tblUsers WHERE strUser='" & Request.Form("strUser") & "' "
ObjRS = ObjConn.execute(sql) ' check for existing user


I was only trying to show the flow rather than provide syntactically

correct code - thats my story and I'm sticking to it

plus why not specify the field rather than use the * in the Select, those * can bite you know (http://www.aspfaq.com/show.asp?id=2188)
"only me" <on*****@hotmail.com> wrote in message
news:Qa******************@newsfep4-glfd.server.ntli.net...
Dim SQL 'A variable for the SQL statement
Dim ObjConn 'A connection varaible
Dim ObjRS

Set ObjConn = Server.CreateObject("ADODB.Connection")
rsSQL = "SELECT * FROM tblUsers WHERE strUser='" &
Request.Form("strUser") &
"' "
ObjRS = ObjConn.execute(sql) ' check for existing user
if ObjRS.EOF = True then ' it's OK its a new user so add them
SQL = "INSERT blah blah
ObjConn.execute(SQL)
else ' reject that user
response.redirect "retry.html"
end if

I'd do it like this
just my 2p worth

"lawtonl" <l.******@totalise.co.uk> wrote in message
news:3f**********************@news.ukonline.co.uk. ..
Hi, i've got a asp page to register a user and check that the username

has not been previously registered, heres the code i have ... that doesnt work

<SCRIPT LANGUAGE=vbscript RUNAT=server>
'Adds a record to the table

Dim SQL 'A variable for the SQL statement
Dim ObjConn 'A connection varaible
Dim ObjRS
Set ObjConn = Server.CreateObject("ADODB.Connection")
Set ObjRS = Server.CreateObject("ADODB.Recordset")


rsSQL = "SELECT * FROM tblUsers WHERE strUser='" &

Request.Form("strUser")
&
"' "

SQL = "INSERT INTO tblUsers "
SQL = SQL & "(strUser, strPwd, strEmail) "
SQL = SQL & "VALUES ('"& Request.Form("strUser") & "', '" &
Request.Form("strPwd") & "','" & Request.Form("strEmail") & "')"

ObjRS.Open rsSQL, "DSN=Project"

If ObjRS.RecordCount > 1 Then

Response.Redirect ("retry.html")

Else
ObjConn.Open "DSN=project"
ObjConn.Execute SQL

End If

ObjConn.Close
Set ObjConn = nothing

Response.Redirect("ok.html")

</script>

i am going the right way about it?
if so where have i gone wrong?
if not could someone please point me in the right direction
any help is appeciated
Regards



Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Gerry Abbott | last post by:
Hi all, Have written some code to limit the concurrent users of a database. Use the Autoexec macro to open a form. When the form opens it increments a value in a table. When the form closes...
3
by: mgPA | last post by:
Short: How can I limit the number of concurrent logins to Access (2000) DB? Long: I seem to be having the problem discussed in previous postings of having more than 9 or 10 concurrent logins. ...
10
by: Conformix Sales | last post by:
Any thought about how can I stop a user from logging into the application multiple times. I am using forms authentication.
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
6
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class...
1
by: pmorrison | last post by:
Hi, I am using a MySQL database and have email address as the Primary Key. I also store a username of which there should not be duplicates. I am trying to check for this by doing the following:...
1
by: shivkumar2004 | last post by:
Hi!, I am developing a chat system using vb.net in vs 2005. I am getting the following error while registering the events. error details: System.InvalidOperationException was unhandled...
0
by: shivkumar2004 | last post by:
Hi, I m getting the following error while registering the events on client appl. error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Exception...
10
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following three files. 1. Users.aspx is a webpage that uses the <asp:ObjectDataSourcecontrol to populate a simple <asp:ListBoxcontrol. 2. The UserDetails.cs file creates a Namespace...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.