egturnkey Posted January 15, 2010 Share Posted January 15, 2010 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 More sharing options...
RaythMistwalker Posted January 15, 2010 Share Posted January 15, 2010 can i see the login form please. Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995853 Share on other sites More sharing options...
egturnkey Posted January 15, 2010 Author Share Posted January 15, 2010 can i see the login form please. there is no login form test it here, http://www.manalnor.com/test/admin thanks in advance Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995854 Share on other sites More sharing options...
RaythMistwalker Posted January 15, 2010 Share Posted January 15, 2010 k i see, basically when you run the showlogin() function your automatically telling it to set to show the error echo. Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995856 Share on other sites More sharing options...
Felex Posted January 15, 2010 Share Posted January 15, 2010 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. Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995861 Share on other sites More sharing options...
egturnkey Posted January 15, 2010 Author Share Posted January 15, 2010 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 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> Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995868 Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2010 Share Posted January 15, 2010 What web server are you using (Apache, IIS, other) and is php running as a server module or as a CGI application? Link to comment https://forums.phpfreaks.com/topic/188629-login-not-working-at-all/#findComment-995883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.