Jump to content

Recommended Posts

when i log in

 

i saw this error... please help

 

Warning: Cannot modify header information - headers already sent by (output started at /home/ocmpq/public_html/index.php:3) in /home/ocmpq/public_html/index.php on line 94

 

Warning: Cannot modify header information - headers already sent by (output started at /home/ocmpq/public_html/index.php:3) in /home/ocmpq/public_html/index.php on line 95

 

Warning: Cannot modify header information - headers already sent by (output started at /home/ocmpq/public_html/index.php:3) in /home/ocmpq/public_html/index.php on line 99

 

 

 

 

here's my code

 

<!DOCTYPE html>
<html lang="en">

<?php include('include/header.php'); ?>
<body>
<?php include('include/container.php'); ?>
    
        <div id="main">
            <section id="content">
                <div id="left">
                    <h3>Navigation</h3>
				<div style="border: 1px solid #000000; margin-top: 20px; margin-left: 10px; margin-right: 10px; margin-bottom: 20px; background-color: #F5F5FF; ">                              
<?php 

mysql_connect("localhost","mycpaneluser","mycpanelpass") or die(mysql_error()); 
mysql_select_db("ocmpq_login") or die(mysql_error()); 

$errors="";
$message="";

if(isset($_COOKIE['ID_my_site']))

{ 
	$username = $_COOKIE['ID_my_site']; 
	$pass = $_COOKIE['Key_my_site'];

	 	$check = mysql_query("SELECT * FROM students  WHERE username = '$username'")or die(mysql_error());

	while($info = mysql_fetch_array( $check )) 	
		{
		if ($pass != $info['password']) 
			{
			 			}

		else
			{
			header("index.php");
			}
		}
}

if (isset($_POST['submit'])) 
{ 

	if(!$_POST['username'] | !$_POST['pass']) {
		die('You did not fill in a required field...<a href=index.php>Back</a>');
	}

if (empty($errors)){
	//continue
		//Check for valid type
		$allowed_types = array('students','faculty');
		if (!in_array($_POST['type'],$allowed_types)){
			$errors .= "Please select a valid account type.";
		}else{
			$typecheck = $_POST['type'];
		}	

if (empty($errors)){
	//continue
		if (get_magic_quotes_gpc()){
			function stripslashes_deep($value)		{
			$value = is_array($value) ?
			array_map('stripslashes_deep', $value) :
			stripslashes($value);
			return $value;
			}
		$_POST = array_map('stripslashes_deep', $_POST);
		}
	}

	}

	$check = mysql_query("SELECT * FROM $typecheck WHERE username = '".$_POST['username']."'")or die(mysql_error());

$check2 = mysql_num_rows($check);

if ($check2 == 0) {
		die('That user does not exist in our database.<a href=index.php>Back</a>');
				}

while($info = mysql_fetch_array( $check )) 	
{

$_POST['pass'] = stripslashes($_POST['pass']);
	$info['password'] = stripslashes($info['password']);
	$_POST['pass'] = md5($_POST['pass']);

	if ($_POST['pass'] != $info['password']) {
		die('Incorrect password, please try again.<a href=index.php>Back');
	}
else 
{ 
{

	 $_POST['username'] = stripslashes($_POST['username']); 
	 $hour = time() + 9600; 

setcookie(ID_my_site, $_POST['username'], $hour); 
setcookie(Key_my_site, $_POST['pass'], $hour);	 
}
switch($typecheck) {
    case "students" :
         header("location:student.php"); 
         break;
    default: 
         header("location:faculty.php"); 
	}
	} 
   } 
} 
else 
{	 

?> 

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> 
<br>

<table border="0"> 
<br>
<tr><th colspan=2><center><h5><b><u>login your account</b></u></h5></center>
</th></tr> 
<tr><th><br>usn / id:</th><th> 
<br><input type="text" name="username" maxlength="20"> 
</th></tr> 
<tr><th><br>password:</th><th> 
<br><input type="password" name="pass" maxlength="20" > 
</th></tr> 
<tr>
		<th><br>login as:</th>
		<th colspan="3">
			<br><select name= "type">
			<?php
				$atype = array(
				"students" => "Student",
				"faculty" => "Teacher"
				);
				foreach($atype as $tkey => $tvalue){
				$selected_type = (isset($_POST['type']) && $_POST['type']==$tkey ? 'selected="selected"' : '');
				echo "<option value=\"$tkey\" $selected_type>$tvalue</option>\r";
				}
				?>	
			</select>
		</th>
	</tr>
        
<tr><th colspan="2" align="center"> 
<br>
<br>
<input type="submit" name="submit" value="Login" style="width: 100px; height: 25px"> 
<br>
<br>
<br>
<br>
</th></tr>  
</table> 
</form> 

<?php 
}
?>
</div>


                </div>
                 <div id="right">
                    <h3>Online Course Materials</h3>
                   <div style="border: 1px solid #000000; 
			width :580px; 
			margin-top: 20px; 
			margin-left: 25px;
			margin-right: 20px;
			margin-bottom: 20px;
			padding:20px 20px 20px 20px ; 		
			background-color: #F5F5FF;">     
			 <?php
			echo "<br />";
			echo "<br />";
			echo "<br />";
			echo " &nbsp<b><i>AMA Online Course Materials Registration Procedure</i></b>";
			echo "<br />";
			echo "<br />";
			echo " &nbsp &nbsp - Only the faculty members can register a student";
			echo "<br />";
			echo "<br />";
			echo " &nbsp &nbsp - The registration process will require  the students
			<br /> &nbsp &nbsp &nbsp to present their IDs or CORs that will prevent forgeries 
			<br /> &nbsp &nbsp &nbsp in the information they will provide and to confirm which 
			<br /> &nbsp &nbsp &nbsp subjects is the student enrolled.<br>
			<br /><br /> ";
			echo " <p align='justify' style='margin-left:2em; margin-right:2em'> 
					   The project Online Course Material will be a web-based program that 
					can access by the facultyand students of AMA Para?aque. The students must 
					have a registered account so that they can access the website and the
					registration of the accounts of the students must be registered by their 
					teachers to avoid outsiders to register to the  website.
					</p>
					<br />
					<p align='justify' style='margin-left:2em; margin-right:2em'>
					   The full purpose of this project is intended to help the
					students and faculty to gather information from their subjects easily.
					And for the students who has to leave school for a while due to reasonable  
					reasons like death of relatives, with the website they cannot skip some of 
					the lessons in school. </p>"; 

			?>

</div>
</div>
</div>


<?php include('include/footer.php'); ?>

</body></html>

 

Link to comment
https://forums.phpfreaks.com/topic/266503-headers-already-sent-errors/
Share on other sites

You can't use header if you've already sent output through the browser.  Just another example showing that jumping back and forth between HTML and PHP is a bad idea.  Do all of your data handling/processing first, determine if you need to redirect, and, if so, do it right then and there.  If not, only once everything has been stored in variables and ready to be displayed on the screen, should you start writing HTML.

Most likely, you have error reporting off on your local machine, and it only appears to work. While developing, error reporting should always be set to the highest level, and set to display all errors. Make sure you have error reporting set up properly on your local machine by configuring the following directives in your php.ini file:

 

error_reporting = -1

display_errors = On

 

Then restart Apache, and see if you get the same errors displayed. If you don't know where your php.ini file is, create a new script containing only this code and run it. You'll see the path to the file in the first section, under the "loaded configuration file" entry.

Most likely, you have error reporting off on your local machine, and it only appears to work. While developing, error reporting should always be set to the highest level, and set to display all errors. Make sure you have error reporting set up properly on your local machine by configuring the following directives in your php.ini file:

 

error_reporting = -1

display_errors = On

 

Then restart Apache, and see if you get the same errors displayed. If you don't know where your php.ini file is, create a new script containing only this code and run it. You'll see the path to the file in the first section, under the "loaded configuration file" entry.

 

Sir

can i upload the php.ini file in the cpanel??

 

 

I'm on the cpanel right now... there's no error in my localhost...  but in our website.. http://ocm-pq.org/index.php

 

all my scripts have this kind of error...

Most likely, you have error reporting off on your local machine, and it only appears to work. While developing, error reporting should always be set to the highest level, and set to display all errors. Make sure you have error reporting set up properly on your local machine by configuring the following directives in your php.ini file:

 

error_reporting = -1

display_errors = On

 

Then restart Apache, and see if you get the same errors displayed. If you don't know where your php.ini file is, create a new script containing only this code and run it. You'll see the path to the file in the first section, under the "loaded configuration file" entry.

 

Sir

can i upload the php.ini file in the cpanel??

 

 

I'm on the cpanel right now... there's no error in my localhost...  but in our website.. http://ocm-pq.org/index.php

 

all my scripts have this kind of error...

 

No, the error does exist in your localhost server too. It's not just being reported, or it's being masked by a configuration setting. Make the changes to your LOCAL php.ini file, restart Apache, and see if you don't get the same errors.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.