Cannot Modify Header ERROR
Posted: Tue Aug 02, 2011 3:36 pm
I am getting errors trying to redirect after login information is verified, I have used this same code on my school server with their database, and have had not 1 error while developing things their. However now I have used the same code on a go-daddy linux box and get errors. Any help is appreciated, I have already read about 8 forums all with what was thought to be useful but when tried did not help the problem what so ever.
khockenberry1734@gmail.com if any assistance could be provided
Checked for extra lines of code [white space]
Tried re arranging the code several different ways also.
ERRORS:
[text]1-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 66
2-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 67
3-Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 69
4-Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 69
5-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 73[/text]
CODE:
Thanks!
khockenberry1734@gmail.com if any assistance could be provided
Checked for extra lines of code [white space]
Tried re arranging the code several different ways also.
ERRORS:
[text]1-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 66
2-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 67
3-Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 69
4-Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 69
5-Warning: Cannot modify header information - headers already sent by (output started at /home/content/50/8151650/html/TSP/Html/trial.php:6) in /home/content/50/8151650/html/TSP/Html/trial.php on line 73[/text]
CODE:
Code: Select all
<!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>Untitled Document</title>
<style type="text/css">
#TOP {
width:100%;
background-color:#5d085d;
height:80px;
}
</style>
</head>
<body>
<?
$DEBUG = 1;
include("global2.inc.php");
//Connect To Database
HOSTNAME
USER
PASSWORD
// mysql_connect($hostname,$username, $password) or die ('Unable to connect to database! Please try again later.');
// mysql_select_db($dbname);
// If Logout Selected Unset User and Admin User Cookies
if(isset($_POST['Logout'])){
setcookie('user',$user, time()-3600);
setcookie('password',$pass, time()-3600);
setcookie('adminuser',$user, time()-3600);
setcookie('adminpassword',$pass, time()-3600);
}
if(isset($_COOKIE['user']) or ($_COOKIE['adminuser'])){
header("location:loggedin2.php");
}
// If Login attempted
if(isset($_POST['Submit'])){
// Connect to server and select databse.
mysql_connect($hostname, $username, $password)or die("Cannot Connect");
mysql_select_db($dbname)or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$user = $myusername;
$pass = $mypassword;
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE user='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
if(isset($_COOKIE['user'])){
setcookie('user',$user, time()-3600);
setcookie('password',$pass, time()-3600);
}
if(isset($_COOKIE['adminuser'])){
setcookie('adminuser',$user, time()-3600);
setcookie('adminpassword',$pass, time()-3600);
}
setcookie('user',$user);
setcookie('password',$pass);
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
?>
<input type="hidden" name="user" value="<? print $myusername ?>"/>
<? header("location:loggedin2.php");
}
}
?>
<div id="TOP">
<font color="#000000">
<form name="form1" method="post" action="trial.php">
<font color="#FFFFFF">
<table>
<Tr><Td rowspan="2"><h1>Kyle Hockenberry's Site</h1></Td>
<td style="padding-left:500px;" valign="bottom">UserName</td>
<td valign="bottom">Password</td>
</Tr><tr>
<td style="padding-left:500px;"><input name="myusername" type="text" id="myusername"></td>
<td><input name="mypassword" type="password" id="mypassword"></td>
<td><input type="submit" name="Submit" value="Login" /></td><td><? if(isset($_POST['Submit'])){
echo ('<font color="#FFFFFF" size="-1"><i>* Wrong Username or Password</i></font>');
}
?></Td></tr>
</table>
</font>
</form>
</font>
</div>
</body>
</html>
Thanks!