SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function VerifyUser( $Username,$Password )
    {
    		$result = mysql_query( "SELECT Username FROM cb_accounts WHERE Username='$Username' AND Password='$Password'" );
    		if ( $row = mysql_fetch_array($result) )
    			return true;
    		else
    			return false;
    }
    Would you say that this code is optimal or somehow insecure? I always make a check if ( VerifyUser($user,$pass) ).. Usually the logins are stored in a cookie.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks okay to me but just optimize it a bit I would use

    function VerifyUser( $Username,$Password )
    {
    $result = mysql_query( "SELECT Username FROM cb_accounts WHERE Username='$Username' AND Password='$Password'" );
    return mysql_num_rows($result);
    }

    //Sample Usage
    if (VerifyUser($Username, $Password)) {
    print "User Okay";
    }
    else {
    print "User not okay";
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •