/    Sign up×
Community /Pin to ProfileBookmark

a http authentication problem please help!

Ok i have my auth.php and my MySQL database with 2 users in the database the passwords are encrypted with md5 and I cant get it to work properly it wont let me into my privet area on my site please help.

My auth.php is (Where USERNAMEis my username, PASSWORDis my password, DATABASE is my database name, TABLE is my table name)

<?php # login.phpl
if (!isset($_SERVER[‘php_auth_user’])) {
header(“WWW-Authenticate: Basic realm=”FSCO Login.””);
header(“HTTP/1.0 401 Unauthorized”);
echo “Sorry – You need a valid username and password to access this area of the website!n”;
exit;

} else {
mysql_connect(“localhost”, “USERNAME”, “PASSWORD”) or die(‘Error!!!!’ . mysql_error());
mysql_select_db(“DATABASE”) $md5pass = md5($_SERVER[php_auth_pw]) or die(‘Error!!!!’ . mysql_error());
$result = mysql_query(“select user_id from TABLE where username = ‘{$_
SERVER[‘php_auth_user’]}’ and password = ‘{$md5}’;”) or die(‘Error!!!!’ . mysql_error());

if (mysql_num_row($result)) {
echo “Welcom, {$_SERVER[‘php_auth_user’]} to the user area”;

} else {
header(“WWW-Authenticate: Basic realm=”FSCO Login””);
header(“HTTP/1.0 401 Unauthorized”);
echo “Sorry – You need to enter a valid username and password to access this area of the website!n”;
exit;
}

}
?>

My table has the table headings of user_id, username, password and reg_data. (All are what they say they are but reg_data is the date and time that the user was created.)

Please can anyone help me thank you.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @crypto spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...