Right.
I have had to move host, so I don't know if this is host related or not. I have a simple log in script. It checks the username and password, if they are right it sets a cookie, which then allows you to post stuff to the website. Fairly straightfoward stuff.
However, when I log in, I get the following
Warning: Cannot modify header information - headers already sent by (output started at /home/www/ecpd.co.uk/login.php:16) in /home/www/ecpd.co.uk/login.php on line 59
login success
attemtping to redirect
Click here if you do not wish to wait
Warning: Cannot modify header information - headers already sent by (output started at /home/www/ecpd.co.uk/login.php:16) in /home/www/ecpd.co.uk/login.php on line 65
So it logs in ok. But the redirect does not work. That's problem one.
Problem 2. When you click on "Here" if you do not wish to wait, it then takes you to the place where you are supposed to be able to post information to the site, but it doesn't work. You click here, and when you get there, you get my error message "You do not have permision"
Here's my code.
admin.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>East Coast Parents Diabetic Support Group</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellspacing="0">
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<p><center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
<tr>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("menutable.php"); ?>
</td>
<td width="70%" bgcolor="#FFFFFF" valign="top">
<p><h3></h3><br /><br />
<form action="login.php" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" value="login"/>
</form>
</p>
</td>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("latestnews.php"); ?>
</td>
</tr>
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<p><center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
</table>
</body>
</html>
login.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>East Coast Parents Diabetic Support Group</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellspacing="0">
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<p><center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
<tr>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("menutable.php"); ?>
</td>
<td width="70%" bgcolor="#FFFFFF" valign="top">
<p><h3></h3><br /><br />
<?php
$dbcnx = @mysql_connect('info', 'info', 'info');
if (!$dbcnx) {
echo 'Unable to connect to the ' .
'database server at this time.' ;
exit();
}
// Select the database
if (!@mysql_select_db('info')) {
exit('Unable to locate the ' .
'database at this time.');
}
if ((!isset($_POST['username'])) || (!isset($_POST['password']))){
echo 'Username or Password Incorrect';
exit();
}
else
{
$username = $_POST['username'];
$password = $_POST['password'];
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT password FROM newsposters WHERE username ='$username'";
$result = mysql_query($query);
if (!$result)
{
echo 'Username or Password Incorrect';
}
else
{
$password = mysql_result($result, 0, 'password');
if ($password == $_POST['password'])
{
setcookie ("ecpd", "you are logged in", time()+3600);
echo 'login success <br />';
echo 'attemtping to redirect <br />';
echo '<p>Click <a href=http://www.ecpd.co.uk/newspost.php>here</a> if you do not wish to wait</p>';
header("Location: http://www.ecpd.co.uk/newspost.php"); /* Redirect browser */
}
else
{
echo 'login failed';
}
}
}
?>
</p>
</td>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("latestnews.php"); ?>
</td>
</tr>
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<p><center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
</table>
</body>
</html>
newspost.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>East Coast Parents Diabetic Support Group</title>
</head>
<body>
<table width="100%" height="100%" border="0" cellspacing="0">
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<p><center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
<tr>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("menutable.php"); ?>
</td>
<td width="70%" bgcolor="#FFFFFF" valign="top">
<p><h3></h3><br /><br />
<?php
if (isSet($_COOKIE['ecpd']))
{ ?>
<form action="newsconf.php" method="post">
Enter your name: <input type="text" name="author" /><br />
Enter the title: <input type="text" name="title" /><br />
<br />
<label>Enter the news:<br />
<textarea name="news" rows="10" cols="40">
</textarea></label>
<input type="submit" value="Go!"/>
</form>
<?php
}
else
{
echo 'You do not have permision.';
}
?>
</p>
</td>
<td width="15%" bgcolor="#9697D9" valign="top">
<? include("latestnews.php"); ?>
</td>
</tr>
<tr width="100%" bgcolor="#9697D9">
<td colspan="3" height="5%">
<center><h1>East Coast Parents Diabetic Support Group</h1></center></p>
</td>
</tr>
</table>
</body>
</html>
I checked if the cookie is actually set afterwards, and it is not. So something is stopping it setting the cookie.