brmcdani Posted January 1, 2010 Share Posted January 1, 2010 I am getting the following errors for my mail() code: Warning: mail() expects at most 5 parameters, 9 given in /home/content/s/a/g/sagates/html/contact.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/a/g/sagates/html/contact.php:17) in /home/content/s/a/g/sagates/html/contact.php on line 18 Here is my code <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message'] ; mail( "laaa4@sss.com", "Contact Request", "Name: $name", "Phone Number: $phone", "Email: $email", "Contact Preference: $pref", "Job Type: $type", "Interested in: $kind", "Description: $message"); header( "Location: thankyou.htm" ); ?> Can someone please help me out please? Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/ Share on other sites More sharing options...
premiso Posted January 1, 2010 Share Posted January 1, 2010 $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n" mail( "laaa4@sss.com", "Contact Request", $body); You were using way too many parameters. Combining them into a variable will show you how it should be done. In function calls commas separate parameters. If you wanted to concatenate them periods should have been used. Hope it helps. Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986621 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Great thanks for your help! Now I am getting a parse error and don't get what the deal is on this I checked it over 3-4 times but I am tired! I know it is something simple someone please help! Thanks <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message'] ; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n" mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header( "Location: thankyou.htm" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986630 Share on other sites More sharing options...
premiso Posted January 1, 2010 Share Posted January 1, 2010 You need a semicolon after the $body section: $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; Should solve that syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986632 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Okay this is really wearing me out! Now I get a Cannot Modify Header error at line 21 One more reply please! <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $pref = $_REQUEST['pref'] ; $type = $_REQUEST['type'] ; $kind = $_REQUEST['kind'] ; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header( "Location: thankyou.htm" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986633 Share on other sites More sharing options...
oni-kun Posted January 1, 2010 Share Posted January 1, 2010 You're sending output before the header is sent, remove any whitespace or echo before the header() or you can simply add this code directly after <?php <?php ob_start(); //output buffer Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986634 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Ok I added the ob_start() should there be a a ob_flush() or something like that at the end? It says the error is on the last line of code now? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986637 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.