Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

php warning message

the mail() function

Moderators: macek, egami, gesf

php warning message

Postby ian_ok » Fri Jun 18, 2004 7:48 am

I get the following message:

Warning: mail() expects at most 5 parameters

I know what it means, but how do I get my code to allow more than 5 fields?

This is my send mail code section

elseif (mail($email,$subject,$from,$name,$arrival_day,$arrival_month,$arrival_year,$departure_day,$departure_month,$departure_year,$message))

Thanks Ian
ian_ok
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Jun 18, 2004 7:28 am

Postby gesf » Fri Jun 18, 2004 8:49 am

Example:
Code: Select all
<?php

mail("$to-address", "$subject", "$name wrote:\n\n$comments\n\n\n From: ip-$REMOTE_ADDR", "FROM: $email");

?>


Or...
Code: Select all
<?php

$message = 'Here goes your complete content for the message body!';

mail("$to-address", "$subject", "$message", "FROM: $email");

?>


If you search on the net for mail script you´ll find a lot of them!

Gesf
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

more confused:

Postby ian_ok » Fri Jun 18, 2004 9:09 am

Thanks for that, yes I'm more confused...

I've searched the web (all search engines) and can't really come up with an answer...

So what you are saying is something like this?

$email = 'reservations@somewhere.com;
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$from = $HTTP_POST_VARS['from'];
$name = $HTTP_POST_VARS['name'];
$arrival_month = $HTTP_POST_VARS['arrival_month'];
$arrival_year = $HTTP_POST_VARS['arrival_year'];
$departure_day = $HTTP_POST_VARS['departure_day'];
$departure_month = $HTTP_POST_VARS['departure_month'];
$departure_year = $HTTP_POST_VARS['departure_year'];


elseif (mail($subject,$from,$name,$message,$arrival_day,\n$email,\nn$arrival_month,\nnn$arrival_year,\nnnn$departure_day,\nnnnn$departure_month,\nnnnnn$departure_year,)) {

Or have I lost the plot?

Ian
ian_ok
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Jun 18, 2004 7:28 am

Postby ian_ok » Sat Jun 19, 2004 2:04 am

Ok I now think I know what you mean:

But it still doesn't work this is what I've changed:

$mail_body = "\nArrival Day: ".$arrival_day;
$mail_body .= "\nArrival Month: ".$arrival_month;
$mail_body .= "\nArrival Year: ".$arrival_year;
$mail_body .= "\nDeparture Day: ".$departure_day;
$mail_body .= "\nDeparture Month: ".$departure_month;
$mail_body .= "\nDeparture Year: ".$departure_year;
$mail_body .= "\nName: ".$name;
elseif(mail($email,$subject,$from,$message,$mail_body)) {

Thanks

Ian
ian_ok
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Jun 18, 2004 7:28 am

Postby ian_ok » Sat Jun 19, 2004 2:08 am

I get an unexpected elseif error.

If I remove it I get:

Parse error: parse error, unexpected '{' in \\nas12ent\domains\c\mywebsite.com\user\htdocs\bookings_mail.php on line 43
ian_ok
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Jun 18, 2004 7:28 am

Postby WiZARD » Sat Jun 19, 2004 3:12 am

wrong again, use this template (from http://www.php.net/manual/en/function.mail.php):
mail("nobody@example.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}", "-fwebmaster@{$_SERVER['SERVER_NAME']}");
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol

Postby ian_ok » Sat Jun 19, 2004 4:39 am

Thanks all,


I've now got it working - now working on the date validations.

Ian
ian_ok
New php-forum User
New php-forum User
 
Posts: 9
Joined: Fri Jun 18, 2004 7:28 am

Postby WiZARD » Sat Jun 19, 2004 4:47 am

ian_ok wrote:Thanks all,


I've now got it working - now working on the date validations.

Ian
In what was a problem?
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron