Hi,
I am trying to use authentication script for Admin pages when i try to add links to queries i get this message:
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-7\www\authent.php:14) in c:\program files\easyphp1-7\www\authent.php on line 57
and I cant understand why??
thanks
<?php
include_once ("../sallysurfconnection/header.html");
?>
<!--Space layout image positioning-->
<td colspan="8" valign="top">
<img src="C:\Program Files\EasyPHP1-7\www\Images\1pix.jpg" width="561" height="9">
<h2>Administration site</h2> <align="center">
<br> <br>
<a href="view_All_customers.php">View all customers</a><p>
<a href="loggin.php">Already registered</a>
<?php
$page_title = 'authent.php';
$authorized= FALSE; //initialise variable
if ( (isset($SERVER['PHP_AUTH_USER']) AND isset($SERVER['PHP_AUTH_PW'])) ) {
//include_once ("../sallysurfconnection/mysql_connect.php"); //connect to database script
@ $db = mysql_pconnect("localhost","Admin","admin");
@mysql_select_db(surf_management) OR die ('Could not select the database: '.mysql_error()); //select which datavase to connect to
//if (!isset($SERVER['PHP_AUTH_USER'])) {
// header('WWW-Authenticate: Basic realm="My Realm"');
// header('HTTP/1.0 401 Unauthorized');
// echo 'Text to send if user hits Cancel button';
// exit;
// } else {
// echo "<p>Hello {$SERVER['PHP_AUTH_USER']}.</p>";
// echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
// }
//query database
$query = "SELECT Administrator_First_Name, Administrator_Surname FROM administrator_table
WHERE Admin='{$SERVER['PHP_AUTH_USER']}' AND admin=PASSWORD('{$SERVER['PHP_AUTH_PW']}')";
$result = mysql_query ($query);
$row = @mysql_fetch_array ($result);
if ($row) {//if a record was returned
$authorized = TRUE;
}
}
//if they havent been authrised, create a popup window
if (!$authorized) {
header('WWW-Authenticate: Basic realm="Admin site"');
header('HTTP/1.0 401 Unauthorized'); //for cancellations
}
include_once ("../sallysurfconnection/footer.html");
?>