[SOLVED] ASP-MySQL Username Validation

This is a discussion on "[SOLVED] ASP-MySQL Username Validation" within the Classic ASP section. This forum, and the thread "[SOLVED] ASP-MySQL Username Validation are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2007, 04:18
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
[SOLVED] ASP-MySQL Username Validation

Hello,
I am having a problem here in MySQL Database.
When I use this code in MS Access, It works fine, but when i switch into MySQL I am having problem with this code:

Code: Select all
'If there is no record with the entered username, close connection and go back to login with QueryString
    If rs.recordcount = 0 then
        rs.Close
        conn.Close
        set rs=nothing
        set conn=nothing
        Response.Redirect("login.asp?login=namefailed")
    end if
I have been searching the net but could not understand anything, lol.
Could anyone of you tell me whats wrong with this code, Thanks.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Oct 18th, 2007 at 06:04. Reason: Simplify my question
Reply With Quote

  #2 (permalink)  
Old Oct 19th, 2007, 06:35
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: ASP-MySQL Username Validation

Ok, maybe no one understand my question, let me clear that!

I have this database connection from MS SQL Access I convert it into MySQL:


MS SQL:
Code: Select all
    set conn = server.CreateObject ("ADODB.Connection")        
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("mydatabase.mdb")
    set rs = server.CreateObject ("ADODB.Recordset")        
    'Open record with entered username
    rs.Open "SELECT * FROM userlist where username='"& Username &"'", conn, 1
MySQL:
Code: Select all
    Dim connectionString, conn, rs
    connectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mydatabase; OPTION=4; UID=root; PASSWORD=monie;"
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open(connectionString)
    Set rs = conn.Execute("SELECT * FROM userlist WHERE username='"& Username &"'")
No problem so far, until I reach here:

Code: Select all
'If there is no record with the entered username, close connection
'and go back to login with QueryString with the message username dont exist!
    If rs.recordcount = 0 then '<-- In MySQL, it's like they skips this line!
        rs.close
        conn.close
        set rs=nothing
        set conn=nothing
        Response.Redirect("login.asp?login=namefailed")
    end if
In MS SQL Access, it read the "If rs.recordcount = 0 then" and return an error message to the user "USERNAME DONT EXIST!"
but after using MySQL, the line seems invinsible and it seems that MySQL dont understand it.

Is it something to do with LockType?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Oct 19th, 2007 at 06:59.
Reply With Quote
  #3 (permalink)  
Old Oct 22nd, 2007, 06:06
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: ASP-MySQL Username Validation

Well, nevermind....
I guess everybody in here don't bother much about ASP compare to PHP then..

Lucky I found the solution to this small problem:
Code: Select all
    'If there is no record with the entered username, close connection and go back to login with QueryString    
    If rs.BOF AND rs.EOF Then
        rs.Close
        conn.Close
        set rs=nothing
        set conn=nothing
        Response.Redirect("login.asp?login=usernamefailed")
    End If
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
Reply

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
input $_SESSION['username'] = $username; on login page help Aaron1988 PHP Forum 2 Jan 28th, 2008 14:14
[SOLVED] Ahh! Validation Driving Me Mad! Jack Franklin Web Page Design 4 Jan 13th, 2008 22:38
[SOLVED] PHP welcome username help. Aaron1988 PHP Forum 18 Nov 16th, 2007 17:19
[SOLVED] javascript from validation eon201 JavaScript Forum 2 Oct 24th, 2007 17:41
username validation Monie Classic ASP 0 Sep 9th, 2004 01:53


All times are GMT. The time now is 06:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43