Click to See Complete Forum and Search --> : php authorization help please


adamduritz99
07-06-2001, 03:59 PM
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>

Grizzly
07-06-2001, 07:20 PM
What's the error message?

adamduritz99
07-06-2001, 08:35 PM
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>