How can i make it so....
| From: | Steve Wright | Date: | Wed, 01 Aug 2001 09:37:52 +0000 |
| Subject: | How can i make it so.... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-60608@lists.php.net to get a copy of this message | ||
Hi,
I have modified an authentication script to my own liking, but being new, don't know how to go
about my next stage.
Once the user has inserted the UN, and PW, it is campared against the MySQL database, nowm what i
want to do is get rid of the login form which still appears, and is very annoying. I can't seem
to see anything on this particular subject, but if their is any, can u point me in the right
direction.
It can be viewed at: http://www.stevewrightonline.co.uk/auth/auth.php
UN: guest
PW: guest
Here's the code:
<P>
<FORM ACTION="<? echo "$PHP_SELF"; ?>" METHOD="POST">
<P>UserName:<br>
<input type="text" name="PHP_AUTH_USER" size=15>
</p>
<P>Password:<br>
<input type="password" name="PHP_AUTH_PW" size=15>
</p>
<input type="submit" value="Log In">
</form>
</P>
<?php
$auth = false; // user is not authenticated yet
if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
// Connect the MySQL Database
mysql_connect( **************.net', '**********', '***********' )
or die ( 'Unable to connect to server.' );
// Select database on MySQL server
mysql_select_db( 'Demonstration' )
or die ( 'Unable to select database.' );
// the query
$sql = "SELECT * FROM users WHERE UserName = '$PHP_AUTH_USER' AND Password =
'$PHP_AUTH_PW'";
// Execute 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 ) {
// matching row was found - user authenticated.
$auth = true;
}
}
if ( ! $auth ) {
echo 'Sign In Required.';
exit;
} else {
echo '<p>You are Signed In!</p>';
}
?>