Jump to content

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( "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?

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( "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.

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( "brett.mcdaniel@ttu.edu", "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( "brett.mcdaniel@ttu.edu", "Contact Request", $body);

header( "Location: thankyou.htm" );

?>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.