manicman
08-28-2006, 09:15 AM
I am using this coe and it keeps giving me the error that I have got 6 parameters when only 5 are allowed.
<?php
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
mail( "contac@web.com", "web.com Contact Us",
$name, $email, $message, "From: $email" );
header( "Location: ../thanks.htm" );
?>
I know I could get rid o the $email parameter, but I need that there becase the From:$email does not work it just says the email comes from webmaster@....
Can anyone tell me how to get round the error?
Thanks :)
ronverdonk
08-28-2006, 11:16 AM
You can only have 5 (maximum, not required) parameters in your MAIL() function. PHP manual:
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
I guess the first 2 are to be taken out.
Ronald :cool:
Hope this help.
I rewrote like :
$name = (isset($_REQUEST['name']))?$_REQUEST['name']):exit;
$email = (isset($_REQUEST['email']))?$_REQUEST['email']:exit;
$message = ((isset($_REQUEST['message'])?$_REQUEST['message']:exit;
$body = "$name wrote :<br /><br />".$message;
$headers = "From:$email\n\r"; // this is who submit contact form to you
$headers .= "Content-Type:text/html\n\r"; // output html
// use @ sign to prevent php from outputing errors to users
// mail() return 1 if successful and 0 if not
// if mail() will ensure users knowing if mailing is actually successful or not
if (@mail("yourmail@domain.com","Users Contact",$body,$headers)) {
header( "Location: ../thanks.htm" );
}else {
echo "Our mail server is currently being maintained.<br />Please try again later.<br />Thank you.";
}
This is basic.
For intermediate,you must use session cookie sending time or cacha image to prevent spamming. And also use regular expression to prevent submitting of bad mail.
manicman
08-28-2006, 04:38 PM
That's great, thanks very much. Luckily I only need basic as I only have a small site, not many people to spam me.
d11wtq
08-28-2006, 11:22 PM
That's great, thanks very much. Luckily I only need basic as I only have a small site, not many people to spam me.
Ah OK. Yeah I forgot that small sites needn't worry about spam. Spammers only target big sites. :rolleyes: