Page 1 of 1

PHP Mail() function, need help...

Posted: Mon Feb 19, 2007 6:10 pm
by WithHisStripes
Heya,
So I have a form at http://testing04.firetree.us that has multiple fields, I am using scripts/contact.php file to email the data but it only allows me to send one field using $message
I need to have it send all the fields (ie first_name, last_name, phone, etc...) Can anyone help? Thanks!

Posted: Mon Feb 19, 2007 6:27 pm
by onion2k
You'll have to concatenate the variables into a single string and send that. Something like "Name: ".$name."\nEmail: ".$email."\nAddress: " ... and so forth. Alternatively use a template and str_replace() to insert the variables. Or something. There's loads of options.

Posted: Mon Feb 19, 2007 6:33 pm
by WithHisStripes
Okay you're refreshing my memory here, thanks a ton. Would you be able to give me an example snippet? Here is the code I'm specifically working with:

$message = cleanPosURL($_POST['posText']);

So would I insert ['postText','\n first_name']); or what?

Thanks again!

Posted: Mon Feb 19, 2007 7:16 pm
by iknownothing
basic example...

Code: Select all

$message = Name: $name\nEmail Address: $email\nPhone No.: $phone\nFax No.: $fax\n\nEnquiry:\n$message\n\n--- End of Details ---\n";
with that posText thing... (I dont think its a good idea however, may lead to injections, call the POST into a variable first)

Code: Select all

$message = Name: $name\nText: $_POST['posText']";