wlindy27 Posted October 10, 2009 Share Posted October 10, 2009 Hi, I am new to php and love it already, even though I am bad The code I am trying to use is as follows: <?php $to = "email@here.com"; $subject = " Invite"; $body = $_REQUEST['Email'] ; $URL = "http://www.mysite.com/index.php?p=1_9"; if (mail($to, $subject, $body)) { header ('Location: '.$URL); } else { echo("<p>Message delivery failed...</p>"); } ?> When I want it to navigate to my url in the header, I get this error: Warning: Cannot modify header information - headers already sent by (output started at /home/Username/public_html/email.php:1) in /home/Username/public_html/email.php on line 9 Any help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/ Share on other sites More sharing options...
smerny Posted October 10, 2009 Share Posted October 10, 2009 that means you have output some html before the header call... you can't have any html before it Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934518 Share on other sites More sharing options...
wlindy27 Posted October 10, 2009 Author Share Posted October 10, 2009 Well I don't see where I output any other html, can you tell me where it is? Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934525 Share on other sites More sharing options...
mikesta707 Posted October 10, 2009 Share Posted October 10, 2009 there error tells you were the output is already sent. its on line 1 on email.php. if you have any output at all, even white space, than you must delete it Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934555 Share on other sites More sharing options...
cags Posted October 10, 2009 Share Posted October 10, 2009 Judging by the indentation of your text you have a space (or more than one space) before your <?php, this is considered output. Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934558 Share on other sites More sharing options...
smerny Posted October 11, 2009 Share Posted October 11, 2009 Well I don't see where I output any other html, can you tell me where it is? Output includes everything, even <html>... not only things in the body show us your entire code if you are still uncertain Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934629 Share on other sites More sharing options...
wlindy27 Posted October 11, 2009 Author Share Posted October 11, 2009 That fixed it! Thanks for being so helpful guys! Quote Link to comment https://forums.phpfreaks.com/topic/177234-solved-going-to-url-in-php-script/#findComment-934997 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.