If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > check to see if user exists

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-18-11, 10:30
AndyJay AndyJay is offline
Registered User
 
Join Date: Feb 2008
Posts: 68
check to see if user exists

Hi all...

I have one database running several sites, with one 'user' table.
Each site registration is based around the users email address and password.

Each site uses a global application variable to identify the site. So when a user registers, the application variable for that site is added to the customer table.
I want to allow a user to register using the same email address if they so wish, but not on the same site.

So if a user wants to register myself@myself.com on site 1 they can also register myself@myself.com on site 2. But they cannot register the same email address on the same site.

I can check to see if the user's email address exists in the database using the code below. The registration page submits to itself and requests the email text field to check against.
Code:
if not CustomerRS.eof then response.redirect "UserTaken.asp
At the same time, i need to check if the email address is already registered on that particular site.

Andy
Reply With Quote
  #2 (permalink)  
Old 08-18-11, 11:58
AndyJay AndyJay is offline
Registered User
 
Join Date: Feb 2008
Posts: 68
I tried this but it's not working correctly.

Code:
if not CustomerRS.eof then 
if Request("CustomerEmail")=(CustomerRS.Fields.Item("CustomerEmail").Value) AND (application("ClientID"))=1 then
response.redirect "UserTaken.asp"
Andy
Reply With Quote
  #3 (permalink)  
Old 08-18-11, 21:31
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Going to make a pile of assumptions here as I have nothing else to go on....

Lets assume you have three tables. Customer for storing user details, Site for storing site details and CustomerSite for storing what customers as registered to what sites.... you could have two tables, customer and site with multiple customer records if they register at mutliple sites or you might have one table that has a site field in it that is a free form char value, it doesn't really matter.

Lets assume CustomerSite stores to email address and the site name

Code:
emailAddress = Request("CustomerEmail")
site = Application("siteName")
sqlString = "select CustomerEmail from CustomerSite where Customer.Site = '" + site "' and CustomerEmail = '" + emailAddress + "'"
set conn = Server.CreateObject("ADODB.Connection")
set customerRS = conn.OpenRecordset(sqlString)
if(not(customerRS.EOF)) then
    ' customer exists with same email in same site
else
    ' customer does not exist
end if
With the assumptions and some code corrections the above should do what you want.

Alternatively you could tell us more about your database tables in question and the sql you are using to build your Customer recordset in your example.

Last edited by rokslide; 08-21-11 at 17:37.
Reply With Quote
  #4 (permalink)  
Old 08-19-11, 06:53
AndyJay AndyJay is offline
Registered User
 
Join Date: Feb 2008
Posts: 68
rokslide you're a star

I didn't think of doing it that way!
Works a treat :-)

Thanks again for your time and help!

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On