Answered
Warning: Cannot modify header information error
This is the error i recieve when I use the log in system of my website. The session ID is correctly sent to the database and the form is processed.
Although, when it comes to redirecting to the logged in homepage this error appears. I have tested this exact script with no problems in my computers local host.
WHen uploaded online and tested tho the error appears. Please help!:
Warning: Cannot modify header information - headers already sent by (output started at /home/gr/public_html/members_login_handle.php:6) in /home/gr/public_html/members_login_handle.php on line 97.
The coding for the members_login_handle.php which processes my members_login.php form to login is below:
<?php
session_start();
?><!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"><!-- InstanceBegin template="/Templates/main_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<script type="text/javascript">
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
function disSel(target){
if (typeof target.onselectstart!="undefined")
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined")
target.style.MozUserSelect="none"
else
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
</script>
<script type="text/javascript">
window.onload = function () {
document.body.onselectstart = function () {
return false;
}
document.body.ondragstart = function () {
return false;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Staff Login</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="seo" -->
<meta name="Description" content="" />
<meta name="Keywords" content="" />
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="../stylesheets/main_styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<div id="header">
<div id="logo"><a href="../index.php"><img src="../images/logo.gif" width="156" height="148" border="0" alt="img" title="Logo"/></a></div>
Great Linford
<br />Primary School</div>
<div id="motto"><div id="myarea"><a href="../html_files/student_area.html" >My Area</a></div>
Be proud to do the "Right Thing"
<a href="../html_files/student_area.html"><img src="../images/star.gif" width="89" height="89" border="0" alt="img"/></a></div>
<div id="menu">
<ul>
<li><a href="../index.php" accesskey="1">Homepage</a></li>
<li><a href="../html_files/school_tour.html" accesskey="2">School Tour</a></li>
<li><a href="../html_files/calendar.php" accesskey="3">Calendar</a></li>
<li><a href="../html_files/newsletter.php" accesskey="4">Newsletter</a></li>
<li><a href="../html_files/events.html" accesskey="5">Events</a></li>
<li><a href="../html_files/parents.html" accesskey="6">Parents</a></li>
<li><a href="../html_files/staff.html" accesskey="7">Staff</a></li>
<li><a href="../html_files/contact_us.html" accesskey="8">Contact Us</a></li></ul>
</div>
<div id="content"><!-- InstanceBeginEditable name="page_content" -->
<?php
include_once('members_login_con.php');
$id = $_REQUEST['id'];
$pwd = md5($_REQUEST['pwd']);
if(preg_replace('/[a-zA-Z0-9]/', '', $id)){
echo "Invalid entry"; echo "<br>";
echo "<a href=\"members_login.php\"><br />Please try again</a>.";
}
else{
$check=mysql_query("SELECT * FROM users WHERE email = '".$id."' AND pwd = '".$pwd."'");
$row_num=mysql_num_rows($check);
if($row_num < 1){
echo "The user name and/or password has been entered incorrectly.";
echo "<br />";
echo "<br />";
echo "Please <a href=\"members_login.php\">Try again</a>.";
}else{
$_SESSION['members'] = md5($_REQUEST['number']);
$members = $_SESSION['members'];
$_SESSION['id']=$id;
$check = mysql_query("SELECT*FROM $table WHERE id= '".$id."' AND pwd = '".$pwd."'");
$row_num = mysql_num_rows($check);
if($row_num < 1){
mysql_query("INSERT INTO $table (session,id,pwd) VALUES ('$members','$id','$pwd')");
header('location:"members_area.php?sess='.$URLsession.'"');
}else{
echo "You are not authorised to log in concurrent sessions";
echo "<br />";
echo "<a href=\members_login.php\">Try again</a>";
}
}
}
?>
Thanks and can't wait to hear back with responses. Been trying to fix it for days...
If any additional infomation is required I would be happy to provide it.
Louise
