robert_gsfame Posted August 4, 2009 Share Posted August 4, 2009 i got this code <?php require_once('config.php');?> <?php if(isset($_POST['login'])){ if(empty($_POST['username'])||(empty($_POST['password']))){header('location:failure.php');}}?> when i run it, then this statement appeared CANNOT MODIFY HEADER(HEADER ALREADY SENT can anyone find out which part is wrong? thx Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/ Share on other sites More sharing options...
taquitosensei Posted August 4, 2009 Share Posted August 4, 2009 something in config.php is outputting to the screen. Or you have a space before before one of the <?php's Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890729 Share on other sites More sharing options...
robert_gsfame Posted August 4, 2009 Author Share Posted August 4, 2009 this is what my config.php look like <?php $localhost='localhost'; $username='xxxxxx'; $password='XXXXX'; $database='YYYYYYY'; mysql_connect($localhost,$username,$password); mysql_select_db($database);?> which part is wrong, it seems i don't have any space wrongly placed Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890736 Share on other sites More sharing options...
WolfRage Posted August 4, 2009 Share Posted August 4, 2009 I think your database is spitting out an error, thus the headers are being sent. You should run that page by it's self. Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890741 Share on other sites More sharing options...
PFMaBiSmAd Posted August 4, 2009 Share Posted August 4, 2009 The whole error message states where the output is occurring that is preventing the headers from working. Reading the error message would indicate where to look. The problem is either characters or content being output from the files or due to the Unicode/UTF-8 BOM characters that an editor places at the start of the file. The problem could be with either the main file or the file being included. Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890742 Share on other sites More sharing options...
ToonMariner Posted August 4, 2009 Share Posted August 4, 2009 the second you break out of php and output markup OR whitespace headers are sent. you can prevent this by coding so that all logic is executed/all processing done BEFORE you start building the page OR by using output buffering buffering may not be the best option but if you have lots of legacy code it will solve it in the short term. Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890743 Share on other sites More sharing options...
robert_gsfame Posted August 4, 2009 Author Share Posted August 4, 2009 okay guys thanx A LOT!!!!!! Link to comment https://forums.phpfreaks.com/topic/168827-stupid-question-about-header/#findComment-890747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.