User authentication script problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prendo
Forum Newbie
Posts: 2
Joined: Mon Apr 28, 2003 2:28 pm

User authentication script problem

Post by prendo »

Hi,

I'm a newbie trying to setup a user authentication a script and I'm having some problems with the admin section. I just wondered if anyone would mind helping me out with this.

When I try to go to the admin page I get this error message 'error 500: Internal Server Error with admin script'. I get the same error message when I try to access any file in the directory called 'loginadmin'. Any directories above this directory level are fine.

The code looks like this:

index.php

Code: Select all

<?php include("login.php") ?> 
<?php include("users_db.php") ?> 
<?php include("messages_db.php") ?> 
<center> 
<h2>BGDev Login! admin</h2> 
<BR> 
<b><?php echo $usersdb ?></b> registered users<BR> 
<b><?php echo $messagesdb ?></b> messages<BR><BR> 
<BR> 
<a href="view.php"><?php echo $lang[adminusers] ?></a><BR> 
<a href="sn.php"><?php echo $lang[sendnewsletter] ?></a><BR>

login.php

Code: Select all

<?php 
include("../config.php"); 
$LOGIN = "$admin"; 
$PASSWORD = "$adminpass"; 

function error ($error_message) { 
   echo $error_message."<BR>"; 
   exit; 
} 

if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == "$PASSWORD" )) ) { 
   header("WWW-Authenticate: Basic entrer="Form2txt admin""); 
   header("HTTP/1.0 401 Unauthorized"); 
   error("&"); 
} 
?>

users_db.php

Code: Select all

<?php include("../config.php"); 
$connection = mysql_connect("$server", "$db_user", "$db_pass"); 
$db = mysql_select_db("$database", $connection); 
$query = "SELECT * FROM login"; 
$result = mysql_query($query, $connection); 
$usersdb=mysql_numrows($result); 


?>

messages_db.php

Code: Select all

<?php include("../config.php"); 
$connection = mysql_connect("$server", "$db_user", "$db_pass"); 
$db = mysql_select_db("$database", $connection); 
$query = "SELECT * FROM usermessages"; 
$result = mysql_query($query, $connection); 
$messagesdb=mysql_numrows($result); 
?>
Can anyone see any likely reason why the server is having problems with this set of scripts. I've already spoken to my ISP and they can't see anything wrong. They're basically saying that there is nothing wrong with the server and there must be bugs in the script. I don't believe this because the script is well tested and proven to work. I'm just wondering if it might be something to do with my php.ini file but I'm just guessing really as I'm quite new to this level of scripting. I havn't really used 'header' files before either so I wouldn't have a clue where to start debugging.

I've been trying for weeks to get a decent user authetication script up and running and I'm starting to lose my mind...Any help greatly appreciated :)

Thanks!

?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Please give us your server-configuration.
(OS, webserver/version, php.version/cgi or module)
prendo
Forum Newbie
Posts: 2
Joined: Mon Apr 28, 2003 2:28 pm

Post by prendo »

Volka,

I'm on a UNIX server with PHP/MySQL installed + APACHE

..and I think it's PHPv4.1

I think that's everything, let me know if you need to know anything else.

Thanks
Post Reply