phoenixd said:
I think monaco is correct.cookie must be sent before the headers.Can u post the code ?
Ok, that would be good if that's the problem - don't know how to fix it though. Here's the code for the file monaco pointed out.
////////////////////////////////// Start of functions ///////////////////////////
function user_set_tokens()
{
session_start();
$_SESSION['logged_in'] = "true";
}
function user_login( $admin_username, $password )
{
global $feedback;
global $db;
if ( !$admin_username || !$password )
{
return array('error' => true, 'error_msg' => "Incorrect Username or Password" );
}
$password = md5 ( strtolower ( $password ) );
$query = "SELECT admin_username FROM mnl_admin WHERE admin_username='$admin_username' AND admin_password= '$password'";
$user = $db->get_row( $query );
if ( $db->num_rows < 1 )
{
return array('error' => true, 'error_msg' => "User not found or Password incorrect" );
}
user_set_tokens();
return array('error' => false, 'error_msg' => "" );
}
////////////////////////////////// End of functions ///////////////////////////
require ( "../config.php" );
require ( "../includes/mysql.php" );
//Do not show the login form if the admin session exists
session_start();
if ( $_SESSION['logged_in'] == "true" )
{
header ( "location: admin_welcome.php" );
exit;
}
$mode = $_GET['mode'];
if ( $mode == "confirm" )
$admin_username = $_POST['admin_username'];
$password = $_POST['password'];
{
$result = user_login( $admin_username, $password );
if ( $result['error'] == false )
{
header ( "location: admin_welcome.php" );
exit;
}
}
require ( "admin_common.php" );
require ( "../global_config.php" );
require ( "admin_interface.php" );
require ( "admin_validate_form.php" );
$bgcolour = MAIN_COLOUR;
$header = "LOG IN HERE";
if ( $mode == "confirm" )
$admin_username = $_POST['admin_username'];
$password = $_POST['password'];
{
$result = user_login( $admin_username, $password );
if ( $result['error'] == false )
{
header ( "location: admin_welcome.php" );
exit;
}
}
admin_page_header();
echo "<p> </p>\n";
echo "<p> </p>\n";
echo "<form action=\"index.php?mode=confirm\" method=\"post\">";
echo "<table width=\"50%\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#555555\" align=\"center\">\n";
echo "<tr bgcolor=\"$bgcolour\">\n";
echo "<td class=\"tbody\" colspan=\"2\" align=\"center\"><b>" . $header . "</b></td>\n";
echo "</tr>\n";
$bgcolour = "#FFFFFF";
$column1_width = "30%";
$column2_width = "70%";
$field_width = "35";
// The username
text_input( $bgcolour, "text", $column1_width, $column2_width, "<b>User name</b>", "admin_username", "", $field_width );
// The password
text_input( $bgcolour, "Password", $column1_width, $column2_width, "<b>Password</b>", "password", "", $field_width );
echo "<tr bgcolor=\"$bgcolour\">\n";
echo "<td class=\"tbody\" colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Log In\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
admin_page_footer( $cplinks_version );
?>