Forum Moderators: coopster

Message Too Old, No Replies

Help with emailing form!

Trying to get a script to work

         

dickbaker

9:29 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know nothing about PHP, but a client I'm working for is on an Apache server. So, no CDONTS.

All day long I've been trying to get a script to work that would send the form values. One script I found that worked sent values, but no more than five (got an error message saying that "mail ()" was expecting no more than five parameters).

Anyway, somebody suggested adding additional headers. I did that with this script, but it's still not quite there.

Please, please help!

Here's where I'm at now:

<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($company);
$phone = stripslashes($phone);
$fax = stripslashes($fax);
$address = stripslashes($address);
$city = stripslashes($city);
$state = stripslashes($state);

/* additional headers */
$headers .= "From: $name\r\n";
$headers .= "Email: $email\r\n";
$headers .= "Company: $company\r\n";
$headers .= "Phone: $phone\r\n";
$headers .= "Fax: $fax\r\n";
$headers .= "Address: $address\r\n";
$headers .= "City: $city\r\n";
$headers .= "State: $state\r\n";

mail('myemail@somewhere.com', "Request For News Releases", $headers);
?>

dreamcatcher

9:44 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try the following:


$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($company);
$phone = stripslashes($phone);
$fax = stripslashes($fax);
$address = stripslashes($address);
$city = stripslashes($city);
$state = stripslashes($state);

/* additional headers */
$message = "Name: $name\r\n";
$message .= "Email: $email\r\n";
$message .= "Company: $company\r\n";
$message .= "Phone: $phone\r\n";
$message.= "Fax: $fax\r\n";
$message.= "Address: $address\r\n";
$message.= "City: $city\r\n";
$message.= "State: $state\r\n";

mail('myemail@somewhere.com', "Request For News Releases", $message, "From:$name<$email>");

:)

dickbaker

3:35 am on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, dreamcatcher. Actually, an hour or so after I posted my question, the email arrived with all the field information.

Gotta love Road Runner's new mail server. :(

If you don't mind my asking, why did you suggest the changes that you did?

dreamcatcher

8:36 am on Jul 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, it was just an aternative way of doing the same thing really. I always like to use the mail function with the 4 parameters, as such.

mail($email, $subject, $message, $headers);

No biggie. Glad you got it working ok.