Jump to content

login not working at all


egturnkey

Recommended Posts

Hello friends,

 

I've a problem when i try to login into admin cp of an script

 

take a look

 

the admin cp login should brings username and password from an database table

 

however when i try to login , it keeps showing me login popup even if the username and password was correct.

 

 

here is the code

 


<?if ($allow_page != "1") die("Sorry, there was an error.");?><?
function showlogin() {
    header('WWW-Authenticate: Basic realm="Rapid Search Script :: Admin Area"');
    header('HTTP/1.0 401 Unauthorized');
    echo "Invalid Request. - Please retry.";
    exit;
}

if (!isset($_SERVER['PHP_AUTH_USER']) OR !isset($_SERVER['PHP_AUTH_PW'])) {
showlogin();
}


$sql=mysql_query("SELECT `Value` FROM `general` WHERE `Name` = 'admin_username'") or die (mysql_error());
while($row=mysql_fetch_array($sql)) $guser = "$row[Value]";

$sql=mysql_query("SELECT `Value` FROM `general` WHERE `Name` = 'admin_password'") or die (mysql_error());
while($row=mysql_fetch_array($sql)) $gpass = "$row[Value]";



if ($guser != $_SERVER['PHP_AUTH_USER']) showlogin();
if ($gpass != $_SERVER['PHP_AUTH_PW']) showlogin();

$username = $_SERVER['PHP_AUTH_USER'];
?>

Link to comment
https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/
Share on other sites

there is nothing to set $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] variables after login. post the code which is responsible from login process please.

 

here is, as you can see

 

index.php calls

 

config.php / to connect to database

authenticate.php / which i've posted its code  :shrug:

 

Note it works fine on my home server Appserv which mean the error due to something wrong in my hosting

 

 

 

 


<?
$allow_page="1";
require_once("../includes/config.php");
require_once("includes/authenticate.php");

function keyUsage() {
$sql=mysql_query("SELECT * FROM `api_keys` ORDER BY ID") or die("<b>SQL ERROR:</b> 101, SQL Stats error.");
while($row=mysql_fetch_array($sql)){
$used1= "$row[used]";
$limit1= "$row[Limit]";
$limit = $limit+$limit1;
$used = $used+$used1;
}
if ($used == "") {
return "0";
}else{
return number_format($used*100/$limit, 1) . "%";
}
}

?>


<html>
    <head>
<title>Admin Panel</title>
<LINK href="../style.css" rel="stylesheet" type="text/css">
    </head>
<body>

<table width="790" align="Center"><tr><td colspan="2">
<a href="index.php"><img src="../images/logo.jpg" border="0"></a>

<table width="100%" border="0" cellpadding="0" height="14"><tbody><tr>
<td width="14"><img src="../images/bar_l.jpg"></td>
<td style="background-image: url(../images/bar.jpg);" align="center" class="barText"><b><?=$title?> | Admin Panel</b></td>
<td width="14"><img src="../images/bar_r.jpg"></td>
</tr></tbody></table>

</td></tr><tr>
<td valign="top" align="center">

<b>Welcome to the administration panel</b> <br />
Total Keys Usage: <b><?=keyUsage();?> per day</b>
<Br />

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.