Click here to Skip to main content
12,950,272 members (67,798 online)
Click here to Skip to main content
Add your own
alternative version

Stats

46.4K views
1.5K downloads
19 bookmarked
Posted 9 Sep 2007

Check availability of username in database records

, 9 Sep 2007
Rate this:
Please Sign up or sign in to vote.
This code checks the availability of username in database records.
Screenshot - screenshot.gif

Introduction

This code explain the procedure to check the availability of username in database records. Username is used as identifier for members so it must be unique. Using this code user can check the availability of username from current page.

If username specified by new user already exists in records then message is displayed saying 'this username already exists'.

If username does not exists in records then message is displayed saying 'congratulations you got it'.

This code can be used in all registration pages where username or any other criteria fed by user is required to be unique. '

Using the code

Simply unzip the folder and use the code. Code is in running state.

AJAX is used to check the records in database. Using AJAX we can run any other ASP from from current page.

Step for using code are explained below:

Step 1: Check if user have provided input properly which will be the condition for accessing data from database. For e.g. if we take username availability program then we check whether user have specified the username or not which is to be compared with existing usernames in the database.

Step 2: Create a new XMLHTTP object with following syntax:

var httpob=new ActiveXObject("Microsoft.XMLHTTP")

Step 3: Open this object with Open() method which take three arguments. The first argument defines which method to use when sending request(GET or POST). Next argument specifies the file name which contains the server-side script. We can pass parameters from current page to that file. And the last argument specifies that the request should be handled asynchronously. While opening object file for communication between current page and page accessing database is defined. We can pass the parameters also to that file.

As shown below check.asp file contains server-side script which is accessed from current page and one parameter 'username' is passed. In username parameter we assign the value which will be used as condition for accessing database. Here username is assign to Id given by user.

a=document.form1.username.value
httpob.open("POST"," check.asp?username=" + a ,false);

In check.asp file, username's value is fetched from browser using request.querystring and compared with existing data in database.

If eof file is encountered means that username was not found in the existing records then message is printed saying "This username is available" else Message is printed saying "This username already exists"

Step 4: httpob.send() – A request is send to the server to execute the check.asp file

Step 5: ab1=httpob.responseText – In one array named ab1 object's response text is fetched. (Note: Response text will be the same text which was printed on check.asp file)

Step 6: Alert(ab1) – This message will confirm whether particular username is available or not.


Points of Interest

With small changes this can code can be used for other coding purposes.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Poonam Gandash
Web Developer RPGIS (P) LTD.
India India
BCA - MCA - Mphil Computer Science

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
max_india72-Jun-12 16:58
membermax_india72-Jun-12 16:58 
GeneralMy vote of 3 Pin
tulasiram39757-Jul-11 3:52
membertulasiram39757-Jul-11 3:52 
GeneralMy vote of 5 Pin
eiiov_gr86-Jul-11 23:12
membereiiov_gr86-Jul-11 23:12 
Generalcode Pin
Arun Sreedhar22-Aug-08 1:23
memberArun Sreedhar22-Aug-08 1:23 
Generalhi Pin
bes_saran6-Jul-08 9:00
memberbes_saran6-Jul-08 9:00 
Generalhi all forum member, Pin
bes_saran6-Jul-08 8:59
memberbes_saran6-Jul-08 8:59 
GeneralSome Tips Pin
rilov10-Sep-07 8:13
memberrilov10-Sep-07 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 10 Sep 2007
Article Copyright 2007 by Poonam Gandash
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid