PHP Form returns error : mail expects most 5 parameters?

This is a discussion on "PHP Form returns error : mail expects most 5 parameters?" within the PHP Forum section. This forum, and the thread "PHP Form returns error : mail expects most 5 parameters? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 7th, 2006, 11:35
Junior Member
Join Date: Aug 2006
Location: uk
Age: 25
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Form returns error : mail expects most 5 parameters?

My php code looks like this:
PHP: Select all

<?
  $name  
$_REQUEST['name'] ;
  
$email $_REQUEST['email'] ;
  
$day   $_REQUEST['day'] ;
  
$month $_REQUEST['month'] ;
  
$year  $_REQUEST['year'] ;
  
$message $_REQUEST['message'] ;
  
  
mail"myemailadress-removed-here.com""Message from vistor",
    
$name$email$day$month$year$message"From: $name" );
  
header"Location: http://www.example.com/thankyou.html);
?>
My form is the second form here: http://www.welovespuds.com/contact_us/contact.html

However, I get the folling error message in my browser when the form is submitted:


Warning: mail() expects at most 5 parameters, 9 given in d:\websites\welo381573\www\contact_us\message.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at d:\websites\welo381573\www\contact_us\message.php: 10) in d:\websites\welo381573\www\contact_us\message.php on line
11

(Try it for yourself..)

>Can anyone help? Is it true what the error message seems to imply that a mail() can only take a max of 5 parameters? If so, what is the way around this?

Thanks

Last edited by karinne; Oct 1st, 2007 at 13:41. Reason: Please use the vBcode [ php ] when inserting PHP code in your post.
Reply With Quote

  #2 (permalink)  
Old Sep 7th, 2006, 14:10
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form returns error : mail expects most 5 parameters?

You have 9 parameters to your main command, which is too many.

The first parameter should be the destination email address. That's fine
The second should be the subject. That looks good too.

The third should be the body of the email. This is where I think you have gone wrong - you probably meant to write everything form $email through to $message in the email body, but that's not what you've done. I suggest you write
$embody = "$email $day $month $year $messge";
before your mail command, then just use $embody in your mail() function call.

The last parameter you gave to mail is fine too.
Reply With Quote
  #3 (permalink)  
Old Sep 7th, 2006, 15:43
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: PHP Form returns error : mail expects most 5 parameters?

Regarding your second error message:
Header information is sent to the browser as soon as the page starts being processed. When you are going to use redirection, which is what you effectively are doing, you need to buffer the header output until you are ready to send it.

You do this by having:
Code: Select all
ob_start();
at the very begining of the page and once you have got to the end of your php processing, make the last command;
Code: Select all
ob_end_flush;
Reply With Quote
  #4 (permalink)  
Old Sep 7th, 2006, 16:30
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form returns error : mail expects most 5 parameters?

Quote:
Originally Posted by ukgeoff View Post
Regarding your second error message:
Header information is sent to the browser as soon as the page starts being processed. When you are going to use redirection, which is what you effectively are doing, you need to buffer the header output until you are ready to send it.

You do this by having:
Code: Select all
ob_start();
at the very begining of the page and once you have got to the end of your php processing, make the last command;
Code: Select all
ob_end_flush;
Yes, Geoff ... but the second message may have been caused by the warning message about the email, mightn't it? So sort out the email issue and the header issue goes away anyway?
Reply With Quote
  #5 (permalink)  
Old Sep 7th, 2006, 18:07
Junior Member
Join Date: Aug 2006
Location: uk
Age: 25
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form returns error : mail expects most 5 parameters?

Thank you both Geoff and Graeme.

Yes the second error did resolve itself after fixing the intial problem... All is working now, thanks!
Reply With Quote
  #6 (permalink)  
Old Sep 30th, 2007, 21:07
New Member
Join Date: Sep 2007
Location: USA
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form returns error : mail expects most 5 parameters?

I tried to configure as previously mentioned code below :
PHP: Select all

<?
  $First_Name 
$_REQUEST['First_Name'] ;
  
$Last_Name $_REQUEST['Last_Name'] ;
  
$Phone $_REQUEST['Phone'] ;
  
$Email_Address $_REQUEST['Email_Address'] ;
  
$Comments $_REQUEST['Comments'] ;
  
$EmMsg "$First_Name $Last_Name $Phone" ;

  
mail"formsubmit@emailaddress.com""Form Submit",
  
$EmMsg,$Comments"From: $Email_Address" );
?>
I am now getting an internal server error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Apache/1.3.33 Server at www.domain.com Port 80

In my email however, I can get the first and last name, phone number, and comments. I can not get the email address. Please help.

Last edited by karinne; Oct 1st, 2007 at 13:41. Reason: Please use the vBcode [ php ] when inserting PHP code in your post.
Reply With Quote
Reply

Tags
php, form, returns, error, mail, expects, most, parameters

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] parse error, unexpected T_EXIT in php mail script Posie PHP Forum 8 Dec 13th, 2007 14:21
PHP Mail Submit Form Error longstand PHP Forum 6 Nov 11th, 2007 16:02
Setting up form returns shifty Web Page Design 3 Aug 21st, 2006 16:03
visitors name not displayed in mail after filling in mail form made on earth PHP Forum 7 Nov 16th, 2005 22:43
E-mail form ??????? pittypatter Web Page Design 3 Apr 11th, 2005 23:42


All times are GMT. The time now is 08:22.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43