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);
?>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!
?>