I am half way there. This code will insert the username in the database and if the name is taken it will take the string entered by the user and adds (1) and so on. I still need to work on the AJAX part.
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "MyDSNConnection"
objConn.Open
DIM strUsername, strPassword, strEmail
strUsername = Request.Form("Username")
strPassword = Request.Form("Password")
strEmail = Request.Form("Email")
IF strUsername <> "" AND strPassword <> "" AND strEmail <> "" THEN
DIM mySQL, objRS
mySQL = "SELECT * FROM tblMembers WHERE fUsername = '" & strUsername & "'"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
Response.write mySQL
IF objRS.EOF THEN
objRS.AddNew
objRS("fUsername") = strUsername
objRS("fPassword") = strPassword
objRS("fEmail") = strEmail
objRS("fDateEntered") = Date()
objRS.Update
objRS.Close
Set objRS = Nothing
Response.Write "You have been successfully registered as: " & strUsername
ELSE
DIM X, strTempUsername, intCount, mySQL2, objRS2
DO UNTIL X=True
intCount = intCount + 1
strTempUsername = strUsername & intCount
strUsername = strTempUsername
mySQL2 = "SELECT * FROM tblMembers WHERE fUsername = '" & strUsername & "'"
'Response.write mySQL2
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open mySQL2, objConn, adOpenKeyset, adLockPessimistic, adCmdText
IF objRS2.EOF THEN
X=True
ELSE
intCount = intCount
END IF
LOOP
objRS2.Close
Set objRS2 = Nothing
Response.Write "That username has already been registered. Please click Back on your browser and try a different username. "
Response.Write "We suggest you try the below available username:</p>"
Response.Write "<b>• " & strUsername & "</b>"
END IF
ELSE
Response.Write "Please click Back on your browser and complete the required form fields"
END IF
%>