Jump to content

Warning: Cannot modify header information


jsucupira

Recommended Posts

could some heal with this code? it gives me the error:

Warning: Cannot modify header information - headers already sent by (output started at /home/content/j/s/u/jsucupira/html/members.php:9) in /home/content/j/s/u/jsucupira/html/members.php on line 42

 

I've read that has something to do with spaces or putting the header below something.  I couldn't figure it out.

 

 

<?php
//Connect To Database
$hostname='p50mysql53.secureserver.net';
$username='';
$password='';
$dbname='';
// Connects to your Database
mysql_connect($hostname,$username, $password) OR die(mysql_error());
mysql_select_db($dbname);
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}
//otherwise they are shown the admin area
else
{
echo "Admin Area<p>";
echo "Your Content<p>";
echo "<a href=logout.php>Logout</a>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/76561-warning-cannot-modify-header-information/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.