Warning: Cannot modify header information - headers already sent by (output started at /srv/disk1/1297215/www/higherme.co.uk/Connect_to_MYSQL.php:26) in /srv/disk1/1297215/www/higherme.co.uk/admin_login.php on line 23
This error appears when i try to log in as admin into my websites, also it appears when i try to return using the return button i created. below are the two php scripts which were, the first one is the "admin_login" page which is where the admin aka me will log in and the second is the adminindex which is where the admin will edit the content.
I tried removing spaces which was what some people recommended.
Please help me try to solve this issue. Thanks
<?php
session_start();
if(isset($_SESSION["manager"])){
header("location: indexadmin.php");
exit();
}
//parse the log in form if the user has filled it out and press "log in"
if(isset($_POST["username"])&&isset($_POST["password"])){
$manager = preg_replace('#[^A-Za-z0-9]#i','', $_POST["username"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','', $_POST["password"]);
//connect to my sql database
include "Connect_to_MYSQL.php";
$sql = mysql_query("SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1");
//Makes sure person exist in database with a query
$existCount = mysql_num_rows($sql);//count the rows nums
if($existCount == 1){// evaluate the count
while($row= mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["id"] = $id;
$_SESSION["manager"] = $manager;
$_SESSION["password"] = $password;
header("location:indexadmin.php");
exit();
}else{
echo 'That infromation is incorrect <a href="indexadmin.php">Click Here</a>';
exit();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Login</title>
<link rel="stylesheet" href="../Style/Style.css" media="screen"/>
</head>
<body>
<div align="center" id="mainWrapper">
<?php include_once("Template_header.php");?>
<div id="PageContent">
<p> </p>
<div align="left"style="margin-left:24px">
<p>Hello store manager, what would you like to do today?</p>
<form id="form1" name="form1" method="post" action="admin_login.php">
User Name:<br/>
<input name="username" type="text" id="username" size="40"/>
<br /><br />
<input name="password" type="password" id="password" size="40"/>
<br />
<br />
<br />
<label>
<input type="submit" name="button" id="button" value="Log in"/>
</label>
</form>
<p> </p>
</div>
<p> </p>
<p> </p>
</div>
<?php include_once("Template_footer.php");?>
</div>
</body>
</html>
<?php
session_start();
if(isset($_SESSION["manager"])){
header("location: admin_login.php");
exit();
}
#logs in user must be succseful
#check the manager session value is in the database
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything but numbers and letters.
//run mysql query to be sure this person is an admin and that there password and sessuin cvar equals the same as in the database infroation
//connect to the mysql database
include "Connect_to_MYSQL.php";
$sql = mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");
//Makes sure person exist in database with a query
$existCount = mysql_num_rows($sql);//count the rows nums
if($existCount == 0){ // evaluate the count
header("location: indexadmin.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Admin Area</title>
<link rel="stylesheet" href="../Style/Style.css" media="screen"/>
</head>
<body>
<div align="center" id="mainWrapper">
<?php include_once("Template_header.php");?>
<div id="PageContent">
<p> </p>
<div align="left"style="margin-left:24px">
<p>Hello store manager, what would you like to do today?</p>
<p> </p>
<p><a href="inventroy_list.php">Manage inventroy</a></p>
<p><a href="#">mangage blah blah</a></p>
</div>
<p> </p>
<p> </p>
</div>
<?php include_once("Template_footer.php");?>
</div>
</body>
</html>

New Topic/Question
Reply




MultiQuote








|