mraza Posted October 7, 2009 Share Posted October 7, 2009 hi before i was having problem with PHP version 4.4.9 with header function that i solved by adding a line "AddType x-mapp-php5 .php" now my problem is this when i click submit i get this error : Warning: Cannot modify header information - headers already sent by (output started at /homepages/21/d295542507/htdocs/includes/registration.php:19) in /homepages/21/d295542507/htdocs/includes/registration.php on line 73 and my line 73 is: else {header('Location: payments.php');} and this is code between page you can see line 73 where it redirect: <?php if(isset($_POST['sub1'])){ $title = $_POST['title']; $name = $_POST['name']; $insurance = $_POST['insurance']; $address = $_POST['address']; $phone = $_POST['phone']; $email = $_POST['title']; $registration = $_POST['registration']; $comments = $_POST['comments']; $_SESSION['title'] = $_POST['title']; $_SESSION['name'] = $_POST['name']; $_SESSION['insurance'] = $_POST['insurance']; $_SESSION['address'] = $_POST['address']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['email'] = $_POST['title']; $_SESSION['registration'] = $_POST['registration']; $_SESSION['comments'] = $_POST['comments']; $error = ""; if (!$title) $error = $error."<font color=\"red\">Title </font><br />"; if (!$name) $error = $error."<font color=\"red\">Name</font> <br />"; if (!$insurance) $error = $error."<font color=\"red\">National Insurance Number</font> <br />"; if (!$address) $error = $error."<font color=\"red\">Address</font> <br />"; if (!$phone) $error = $error."<font color=\"red\">Telephone Number</font> <br />"; if (!$email) $error = $error."<font color=\"red\">Email Address</font> <br />"; if (!$error =="") echo "<font color=\"red\"><b>Please Fill in The Following Required Fields: </b></font><br /> $error"; else {header('Location: payments.php');} }elseif(isset($_POST['sub2'])){ $title = $_POST['title']; $name = $_POST['name']; $insurance = $_POST['insurance']; $address = $_POST['address']; $phone = $_POST['phone']; $email = $_POST['email']; $registration = $_POST['registration']; $comments = $_POST['comments']; $_SESSION['title'] = $_POST['title']; $_SESSION['name'] = $_POST['name']; $_SESSION['insurance'] = $_POST['insurance']; $_SESSION['address'] = $_POST['address']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['email'] = $_POST['title']; $_SESSION['registration'] = $_POST['registration']; $_SESSION['comments'] = $_POST['comments']; $error = ""; if (!$title) $error = $error. "<font color=\"red\">Title</font> <br />"; if (!$name) $error = $error. "<font color=\"red\">Name</font> <br />"; if (!$insurance) $error = $error. "<font color=\"red\">National Insurance Number</font> <br />"; if (!$address) $error = $error. "<font color=\"red\">Address</font> <br />"; if (!$phone) $error = $error. "<font color=\"red\">Telephone Number</font> <br />"; if (!$email) $error = $error. "<font color=\"red\">Email Address</font> <br />"; if (!$error =="") echo "<font color=\"red\"><b>Please Fill in The Following Required Fields:</b></font> <br /> $error"; else { header('Location: confirmation.php');}}?> thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/ Share on other sites More sharing options...
mikesta707 Posted October 7, 2009 Share Posted October 7, 2009 you can't have any output at all before the header call. judging by how far down in the code it is, im willing to bet something is output before you try to call that Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932600 Share on other sites More sharing options...
mraza Posted October 7, 2009 Author Share Posted October 7, 2009 here is my complete code file: <?php session_start(); $title = ""; $name = ""; $insurance = ""; $address = ""; $phone = ""; $email = ""; $registration = ""; $comments = ""; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Your description goes here..." /> <meta name="keywords" content="your,keywords,goes,here" /> <link rel="stylesheet" type="text/css" href="../style.css" title="1024px style" media="screen,projection" /> <title>My title</title> </head> <body> <?php include_once("include_header.php");?> <h2>CSCS Registration Form</h2> <br /> <div border="1"><h3> First Registration <a href="bulkregistration.php">Bulk Registration Two</a> </h3></div> <br />Thank you for choosing to book your test with us. <div id="form" style="margin: 20px 90px 10px 90px;"> <?php if(isset($_POST['sub1'])){ $title = $_POST['title']; $name = $_POST['name']; $insurance = $_POST['insurance']; $address = $_POST['address']; $phone = $_POST['phone']; $email = $_POST['title']; $registration = $_POST['registration']; $comments = $_POST['comments']; $_SESSION['title'] = $_POST['title']; $_SESSION['name'] = $_POST['name']; $_SESSION['insurance'] = $_POST['insurance']; $_SESSION['address'] = $_POST['address']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['email'] = $_POST['title']; $_SESSION['registration'] = $_POST['registration']; $_SESSION['comments'] = $_POST['comments']; $error = ""; if (!$title) $error = $error."<font color=\"red\">Title </font><br />"; if (!$name) $error = $error."<font color=\"red\">Name</font> <br />"; if (!$insurance) $error = $error."<font color=\"red\">National Insurance Number</font> <br />"; if (!$address) $error = $error."<font color=\"red\">Address</font> <br />"; if (!$phone) $error = $error."<font color=\"red\">Telephone Number</font> <br />"; if (!$email) $error = $error."<font color=\"red\">Email Address</font> <br />"; if (!$error =="") echo "<font color=\"red\"><b>Please Fill in The Following Required Fields: </b></font><br /> $error"; else {header('Location: payments.php');} }elseif(isset($_POST['sub2'])){ $title = $_POST['title']; $name = $_POST['name']; $insurance = $_POST['insurance']; $address = $_POST['address']; $phone = $_POST['phone']; $email = $_POST['email']; $registration = $_POST['registration']; $comments = $_POST['comments']; $_SESSION['title'] = $_POST['title']; $_SESSION['name'] = $_POST['name']; $_SESSION['insurance'] = $_POST['insurance']; $_SESSION['address'] = $_POST['address']; $_SESSION['phone'] = $_POST['phone']; $_SESSION['email'] = $_POST['title']; $_SESSION['registration'] = $_POST['registration']; $_SESSION['comments'] = $_POST['comments']; $error = ""; if (!$title) $error = $error. "<font color=\"red\">Title</font> <br />"; if (!$name) $error = $error. "<font color=\"red\">Name</font> <br />"; if (!$insurance) $error = $error. "<font color=\"red\">National Insurance Number</font> <br />"; if (!$address) $error = $error. "<font color=\"red\">Address</font> <br />"; if (!$phone) $error = $error. "<font color=\"red\">Telephone Number</font> <br />"; if (!$email) $error = $error. "<font color=\"red\">Email Address</font> <br />"; if (!$error =="") echo "<font color=\"red\"><b>Please Fill in The Following Required Fields:</b></font> <br /> $error"; else { header('Location: confirmation.php');}}?> <br /> <form action="registration.php" method="POST"> <table> <tr> <td align="right"> Title:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="title" value="<?php echo "$title" ?>"> </td> </tr> <tr> <td align="right"> Name:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="name" value="<?php echo "$name" ?>"> </td> </tr> <tr> <td align="right"> National Insurance<br /> Number:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="insurance" value="<?php echo "$insurance" ?>"> </td> </tr> <tr> <td align="right"> Address:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="address" value="<?php echo "$address" ?>"> </td> </tr> <tr> <td align="right"> Tleephone Number:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="phone" value="<?php echo "$phone" ?>"> </td> </tr> <tr> <td align="right"> Email:<span style="color:red;">*</span> </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="email" value="<?php echo "$email" ?>"> </td> </tr> <tr> <td align="right"> CSCS Registration Number: </td> <td> <input style="border:1px solid #4088b8;" type="text" size="29" name="registration" value="<?php echo "$registration" ?>"> </td> </tr> <tr> <td align="right"> Special Accommodations: </td> <td> <textarea style="border:1px solid #4088b8;" type="textarea" cols="30" rows="5" name="comments"> <?php echo "$comments" ?> </textarea> </td> </tr> <tr><td> </td></tr> <tr><td> </td> <td><input type="submit" name="sub1" value="Payment" /> <input type="submit" name="sub2" value="More Information" /></td> </tr> </table> </form> </div> <?php include_once("sidebar.php");?> <?php include_once("include_footer.php");?> </div> </body> </html> and this is working perfectly on my localhost with PHP 5.3.0 Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932604 Share on other sites More sharing options...
mikesta707 Posted October 7, 2009 Share Posted October 7, 2009 so its working? than whats the problem Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932606 Share on other sites More sharing options...
mraza Posted October 7, 2009 Author Share Posted October 7, 2009 its not working on my host server they have PHP 4.4.9 version Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932609 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2009 Share Posted October 7, 2009 Sadly, a lot of development systems using the xAMP all in one packages are NOT setup properly as development systems where the code you get working on them will work on the majority of actual servers. Your development system has output_buffering turned on in the master php.ini. I recommend that you turn it off (it is off on your live server) so that code you develop on your localhost has a chance of working on your live server. Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932615 Share on other sites More sharing options...
mraza Posted October 7, 2009 Author Share Posted October 7, 2009 that is really sad , now i have turned it off next what should i do with my file...i am so confuse i am getting same error...please help Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932629 Share on other sites More sharing options...
mraza Posted October 7, 2009 Author Share Posted October 7, 2009 ok i found the fix i added at the start of the page before anything: <?php ob_start() ; ?> and at the end of the page: <?php ob_flush() ?> Thanks for all...hope it will help for somebody ... Best Wishes Quote Link to comment https://forums.phpfreaks.com/topic/176874-solved-cannot-modify-header-information-error/#findComment-932639 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.