php is a nightmare!

Status
Not open for further replies.

heidi

Baseband Member
Messages
24
hi-
i'm trying to help my bro-in-law out with his website. everything has been okay until he asked for mail forms. ahhhh! "mailto" doesn't work anymore:mad:

so i need to learn php, right? his server can handle this... it has to be something i'm doing. i got the code from www.php.net & tweaked it to fit his site, but get this error when i click submit:

Warning: mail() expects at most 5 parameters, 8 given in /home/southern/public_html/sendmail.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at /home/southern/public_html/sendmail.php:10) in /home/southern/public_html/sendmail.php on line 11


5 parameters? 8? huh!? well anyway, this is what i have in my php file:

<?
$pre = $_REQUEST['pre'] ;
$first = $_REQUEST['first'] ;
$last = $_REQUEST['last'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$message = $_REQUEST['message'] ;

mail( "jbuche@westerniplaw.com", "Feedback Form Results",
$pre, $first, $last, $phone, $message, "From: $email" );
header( "Location: http://www.southerncaliforniapatents.com/thankyou.html" );
?>

this is the page i'm working with is here:
http://www.southerncaliforniapatents.com/contact8.html

mail forms should be pretty easy, right? has anyone seen this or know why mine won't send? thanks so, so much:eek:
 
OK the prototype of mail() is
Code:
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

I can see that your problem is that you are using commas to concatenate the information you want in your email.

Try this instead:
Code:
$formatted_msg = $pre . " " . $first . " " . $last . "\nFrom: " . $email 
   . "\n" . $phone . "\n" . $message;
mail("jbuche@westerniplaw.com","Feedback Form Results", $formatted_msg);

That will solve both of your problems.
 
Here is a simplified version of the way I process my php mail forms (though i have not included any error checking or field handling here ... just the send stuff)


// I set the static features (where its going and its subject

$to = 'emailaddress@theinternet.com';
$subject = 'Mail form query';

//Then I populate the from address and email body from my mail form

$body = "Comment/Query:" . $_POST['CommText'];
$from = "From: " . $_POST['EmailTxt'];

//then i send

mail ($to, $subject, $body, $from);


// and redirect to a confirmation page (where my pages are controlled by variables in the query string)

header("Location: ?hs=9");

//this could easily be "Location: thanks.php" or similar

-----

if you have more than one item you want to include in the message copy i.e. phone number, first name etc...

simply build the $body variable as follows

$body = "Name: " . $_POST['NameTxt'] . " ";
$body = $body . "PhoneNo: " . $_POST['PhoneTxt'] . " ";
$body = $body . "Comment/Query:" . $_POST['CommText'] . " ";

Hope this is of some help to you!
 
The reason is because you are using 8 variables/strings seperated by commas, php thinks those are parameters for the mail function...
You need to combine the variables into 1 variable and put the string into the mail function.

PHP:
$string = "$pre, $first, $last, $phone, $message";
mail( "jbuche@westerniplaw.com", "Feedback Form Results",
$string, "From: $email" );

Or change the string if i didnt pick up on that one correctly.
 
Status
Not open for further replies.
Back
Top Bottom