I'm trying to authenticate members by using php and MySQL.

This is what I've come to so far:


$auth = false; // Assume user is not authenticated

if (isset( $email ) && isset($password)) {

    // Connect to MySQL

    mysql_connect( 'localhost', 'Xephiroth', 'lordoftherings' )
        or die ( 'Unable to connect to server.' );

    // Select database on MySQL server

    mysql_select_db( 'members' )
        or die ( 'Unable to select database.' );

    // Formulate the query

    $sql = "SELECT * FROM memberinfo WHERE
            email = '$email' AND
            password = '$password'";

    // Execute the query and put results in $result

    $result = mysql_query( $sql )
        or die ( 'Unable to execute query.' );

    // Get number of rows in $result.

    $num = mysql_numrows( $result );

    if ( $num != 0 ) {

        // A matching row was found - the user is authenticated.

        $auth = true;



if ( ! $auth ) {

    header( 'WWW-Authenticate: Basic realm="Members only"' );
    header( 'HTTP/1.0 401 Unauthorized' );
    echo 'Authorization Required to enter the member area';

} else {

echo '


'; } ?>

How do I make the authentication to go to site:

Where $charnick is brung from the DB line who was authenticated?

So that Peter won't end up at John 's membersite?

Thanks for your time and expertese!

Best regards Cato

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to