PHP Mail() function, need help...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

PHP Mail() function, need help...

Post 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!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post 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!
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post 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']";
Post Reply