SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    bangalore
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i need to check existing username using ASP

    ----------------------------------------------------------------
    hai
    i need a help
    my coding is as follows
    the problem is without checking anything all users names and password are storing in database,i need to check existing username
    [code]
    <%
    DIM objConn
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath ("db/db_name.mdb") & ";"
    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 user_list WHERE Username = ' " & strUsername & " ' "
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.CursorType = 1
    objRS.lockType = 3
    objRS.Open my_SQL, objConn

    IF objRS.EOF THEN
    objRS.AddNew
    objRS("Username")=strUsername
    objRS("Password")=strPassword
    objRS("Email")=strEmail
    objRS("date")=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 & " ' "
    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> " & strUsername2 & "</b>"
    END IF

    ELSE
    Response.Write "Please click Back on your browser and complete all three fields"
    END IF
    %>
    [code]

    thanks in advance

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Usernames

    try this
    Code:
    IF len(strUsername)>0 AND len(strPassword)>0 AND len(strEmail)> 0 THEN
    'user populated the fields
    DIM mySQL, objRS
    mySQL = "SELECT * FROM user_list WHERE Username = ' " & trim(strUsername) & " ' "
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.open mySQL, objConn
    
    if objRS.eof then objRS.close() mySQL = "insert into user_list (Username, Password ,Email, dateUpdated)"_ &" values('"&replace(strUsername, "'","''")&"', '"&strPassword&"', '"&strEmail&"', date())" objRS.open mySQL, objConn response.write("Success") else response.write("there was another username") end if set objRS = nothing
    else response.write("Fill out all the fields") end if
    you need to do more validations of course


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •