You are here: Re: Cannot modify header information - headers « PHP Programming Language « IT news, forums, messages
Re: Cannot modify header information - headers

Posted by Rik on 07/21/07 14:39

On Sat, 21 Jul 2007 15:56:06 +0200, <vncntj@hotmail.com> wrote:

> I went through and removed the HTML tags, but I'm still getting the
> error:
>
> "Warning: Cannot modify header information"

You misunderstood. I only pointed out you have output (tags, echo =

statments) before a header() call. Wether you have them hardcoded outsid=
e =

the <?php ?> echo echo/print them makes absolutely no difference. The =

header() call should be one of the very first things you do, not the las=
t.

Your code would be like:

<?php
require_once('blah_class.php');
if (isset($_POST['submitted'])) {
$db =3D new db_class;
$l =3D $_POST['login'];
$p =3D $_POST['password'];
if (!$db->connect($this->host, $this->user, $this->pw, $this->db,
true))
$db->print_last_error(false);
$r =3D $db->select("Select login from blah_table Where login=3D'$l' AND
password=3D'$p'");
if(@mysql_num_rows($r) =3D=3D 1)
{
while ($row=3D$db->get_row($r, 'MYSQL_ASSOC')) {
header("Location:test.htm");
exit;
}
}
else {
$msg =3D "No match";
}
}
?>
<html>
<head>
<title>WTW</title>
</head>
<body>
<table width=3D"95%" border=3D"0" align=3D"center" cellpadding=3D"0"
cellspacing=3D"0">
<tr>
<td height=3D"500" valign=3D"top" background=3D"images/cc_bg.gif">
Please Login
<form action=3D"login.php" method=3D"post">
<input type=3Dtext name=3Dlogin size=3D20 maxlength=3D40><br />
<input type=3Dpassword name=3Dpassword size=3D20 maxlength=3D20><br />
<input type=3Dsubmit name=3Dsubmit value=3DLogin><br />
<input type=3Dhidden name=3Dsubmitted value=3DTRUE>
</form>
</td>
</tr>
</table>
<?php
echo $msg;
?>
</body>
</html>


-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация