Jump to content

mail() ERROR


brmcdani

Recommended Posts

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( "[email protected]", "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?

Link to comment
https://forums.phpfreaks.com/topic/186831-mail-error/
Share on other sites

  $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"

  mail( "[email protected]", "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.

Link to comment
https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986621
Share on other sites

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( "[email protected]", "Contact Request", $body);

header( "Location: thankyou.htm" );
?>

Link to comment
https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986630
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986632
Share on other sites

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( "[email protected]", "Contact Request", $body);

header( "Location: thankyou.htm" );

?>

Link to comment
https://forums.phpfreaks.com/topic/186831-mail-error/#findComment-986633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.