Wireframe Posted March 24, 2012 Share Posted March 24, 2012 Hey everyone, I'm new to this forum and I came here looking for some help with PHP. I've just started getting into PHP and you guys are probably a smile ahead. So basically, I have some inputs and want them to be sent to my email in a basic layout shown below. Inputs: Title = _title Forum Name = _forumname Name = _irlname Age = _age I want the email to be sent to me like: Email Title --------------- Forum Name: TextGiven Real Life Name: TextGiven Age: TextGiven Here is my current code which titles the email correctly, but I want to figure out how to make $message set to the example email I showed above. <?php $to = "******@*********.net"; $subject = $_REQUEST['_title']; $headers = "From: ***** Applicant \r\n"; $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n"; $message = $_REQUEST['_forumname' & '_irlname']; <--- Part I want fixed if(mail($to, $subject, $message, $headers)) { echo 'MAIL SENT'; } else { echo 'MAIL FAILED'; } ?> I have this code, and it works. But I want $message = "" to make the message contain not just the forum name, but as well as the name, age, and all other inputs I want. Quote Link to comment https://forums.phpfreaks.com/topic/259636-requesting-multiple-values-to-set-to-a-variable/ Share on other sites More sharing options...
codebyren Posted March 24, 2012 Share Posted March 24, 2012 For an email message with so few lines and variables, the simplest way to do this is probably to build the message line by line. Something like: <?php // The \r\n indicates a new line or else your message will render as a single line // The period before the '=' sign on all except the first line says append this value to the current value of $message $message = "{$_REQUEST['_title']} \r\n"; $message .= "--------------------- \r\n"; $message .= "Forum Name: {$_REQUEST['_forumname']} \r\n"; $message .= "Real Life Name: {$_REQUEST['irlname']} \r\n"; $message .= "Age: {$_REQUEST['_age']} \r\n"; ?> You could also look into what's known as herdoc syntax which is basically a pre-formatted string that can have variables scattered throughout it. Quote Link to comment https://forums.phpfreaks.com/topic/259636-requesting-multiple-values-to-set-to-a-variable/#findComment-1330807 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.