Hey everyone, I'm a bit of a newbie to php scripting, and have unfortunatly hit my first bump on my first php page!! I've basically placed a php contact form on my page supplied by somebody else, and altho it kinda works (it sends me mail!) they person sending the message doesn't get redirected to my "thank you page like they should, instead the following two errors are displayed: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /customers/landmark-joinery.co.uk/landmark-joinery.co.uk/httpd.www/contact.php:44) in /customers/landmark-joinery.co.uk/landmark-joinery.co.uk/httpd.www/securimage.php on line 1 Warning: Cannot modify header information - headers already sent by (output started at /customers/landmark-joinery.co.uk/landmark-joinery.co.uk/httpd.www/contact.php:44) in /customers/landmark-joinery.co.uk/landmark-joinery.co.uk/httpd.www/contact.php on line 239 Any idea why this is happening? and how I can correct the problem?? I can supply the html/php code if you require. Thanks in advance for any help given! Bozo
could be whitespace like SecureCP said. but the problem is your script is trying to modify the HTTP headers after the page is being displayed. So what you have to do is be sure there's no HTML (including spaces) sent to the browser before the redirect.
So I'd read about the whitespace before php code before and made sure that I didn't have any, but didn't know you couldn't have html code before the php, so I made a page header and page footer php page and placed the html coding in them then set links up in the php script...works a treat. Thank you very much guys!
<?php // Check to see if the form was submitted by checking one of the post variables if(isset($_POST['first_name'])) { // check your input, don't want your form to be used for spam! ... // send your message mail(...); // redirect to confirmation page header('Location: /thanks.php'); } ?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> ... </form> Code (markup): Here's the basic layout for a contact form page
only BOM I'm aware of is UTF W/ BOM and its a file type. If a text file is saved as UTF w/BOM it can result in php pages not working properly though IIRC the error is different. BOM stands for Byte Order Mark. doubt that's your issue.
Tick....Tock.... Tick....Tock.... Tick....Tock.... Tick....Tock.... Tick....Tock....BOOOM!! Actually you can redirect from PHP after you sent headers - but its kinda sneaky I use it a lot on PHP Logout forms - Just do a google search on 'ultimate page redirection techniques webmaster-a' and you will get it - its on a whole useful page about redirect techniques!