php authorization help please

Sharky Forums


Results 1 to 3 of 3

Thread: php authorization help please

  1. #1
    Expensive Sushi
    Join Date
    Apr 2001
    Posts
    15

    Post php authorization help please

    uhh...why isnt this working? i can't figure it out
    --------------
    <?php

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

    if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
    // Connect to MySQL

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

    // Select database on MySQL server

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


    // Formulate the query

    $sql = "SELECT * FROM resellers WHERE
    username = '$PHP_AUTH_USER' AND
    password = '$PHP_AUTH_PW'";

    // 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 ) {


    echo 'Authorization Required.';

    ?>

    <form name="login" method="post" action="<?PHP echo $PHP_SELF ?>">
    <br>
    <table width="300" border="0" cellspacing="0" cellpadding="2">
    <tr valign="top">
    <td>Username </td>
    <td>
    <input type="text" name="username" value="<?php echo $PHP_AUTH_USER ?>">
    </td>
    </tr>
    <tr valign="top">
    <td>Password</td>
    <td>
    <input type="text" name="password" value="<?php echo $PHP_AUTH_PW ?>">
    </td>
    </tr>
    <tr valign="top">
    <td>Referral ID</td>
    <td>
    <input type="text" name="refid">
    </td>
    </tr>
    <tr valign="top">
    <td> </td>
    <td>
    <input type="reset" name="Reset" value="Reset">
    <input type="submit" name="Submit" value="Log-In">
    </td>
    </tr>
    </table>
    <br>
    <br>
    </form>

    <?php
    exit;

    } else {

    echo '<P>You are authorized!</P>';
    }

    ?>
    ------------------


    thanks
    peace
    sean

    ------------------
    <a href="http://www.blingice.com">The world in a shade of Bling Bling</a>
    <a href="http://www.blingice.com">The world in a shade of Bling Bling</a>

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    What's the error message?

  3. #3
    Expensive Sushi
    Join Date
    Apr 2001
    Posts
    15

    Post

    awww, don't worry about it. i fixed it. kinda of a dumb mistake too. i'll give you a hint. the problem is in my form.

    peace
    sean

    ------------------
    <a href="http://www.blingice.com">The world in a shade of Bling Bling</a>
    <a href="http://www.blingice.com">The world in a shade of Bling Bling</a>

Posting Permissions

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