nouse4one Posted August 10, 2010 Share Posted August 10, 2010 I am experiencing compleate brain failure here please help if you can. This is my email script, how do i include multiple input, into the $body tag? example: vieweremail + comments + phonenumber + alot other stuff?? As of now i can only make it include 1 user input field thats is 'vieweremail'. <?php $to = $_POST['email_addy']; $subject = "RE: your dating app"; $body = $_POST['vieweremail']; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/ Share on other sites More sharing options...
sinista Posted August 10, 2010 Share Posted August 10, 2010 $body = "some"; $body .= " other stufff"; echo $body; will out put some other stuff Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097727 Share on other sites More sharing options...
nouse4one Posted August 10, 2010 Author Share Posted August 10, 2010 <?php $to = $_POST['email_addy']; $subject = "RE: your dating app"; $body = $_POST['vieweremail']; $body .= $_POST['viewername']; echo $body; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> That is a big no go. I have over 30 fields i want to be included in my email body, can you give me a example im not getting it. Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097731 Share on other sites More sharing options...
TOA Posted August 10, 2010 Share Posted August 10, 2010 That is a big no go. I have over 30 fields i want to be included in my email body, can you give me a example im not getting it. Thats the exact way ist's supposed to work, so echo your POST values to see that things are being populated correctly. What echoes for $body? And try taking it out of the if statement to see if it works without it Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097732 Share on other sites More sharing options...
sinista Posted August 10, 2010 Share Posted August 10, 2010 or this method $a ="one and "; $b =" two"; $body =$a.$b; if you have lots of things to add put them in a loop foreach ($_REQUEST as $item) { $body .= $item; } you just want to add stuff to the body part of the email right? Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097735 Share on other sites More sharing options...
nouse4one Posted August 10, 2010 Author Share Posted August 10, 2010 Thank you i got it to work, a bit buggy however it is very usable. Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097739 Share on other sites More sharing options...
nouse4one Posted August 10, 2010 Author Share Posted August 10, 2010 Yes im only writing stuff into the body of the email message <?php $to = $_POST['email_addy']; $subject = "RE: your dating app"; $body = $_POST['vieweremail']; $body .= $_POST['viewername']; $body .= " "; $body .= $_POST['areacode']; $body .= " "; $body .= $_POST['phone2']; $body .= " "; $body .= $_POST['phone3']; $body .= " "; $body .= $_POST['viewercomments']; $body .= " "; $body .= $_POST['q1']; $body .= " "; $body .= $_POST['q2']; $body .= " "; $body .= $_POST['q3']; $body .= " "; $body .= $_POST['q4']; $body .= " "; $body .= $_POST['q5']; $body .= " "; $body .= $_POST['q6']; $body .= " "; $body .= $_POST['q7']; $body .= " "; $body .= $_POST['q8']; $body .= " "; $body .= $_POST['q9']; $body .= " "; $body .= $_POST['q10']; $body .= " "; $body .= $_POST['q11']; $body .= " "; $body .= $_POST['q12']; $body .= " "; $body .= $_POST['q13']; $body .= " "; $body .= $_POST['q14']; $body .= " "; $body .= $_POST['q15']; $body .= " "; $body .= $_POST['q16']; $body .= " "; $body .= $_POST['q17']; $body .= " "; $body .= $_POST['q18']; $body .= " "; $body .= $_POST['q19']; $body .= " "; $body .= $_POST['q20']; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> this works buts is there a better way? Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097741 Share on other sites More sharing options...
freeloader Posted August 10, 2010 Share Posted August 10, 2010 foreach ($_POST as $post) { $body .= $post." "; } Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097747 Share on other sites More sharing options...
sinista Posted August 10, 2010 Share Posted August 10, 2010 I guess there a billion ways to do it, when I'm at work I create a table in HTML with all the data filled in, then add the table to the $body variable, so when the reader gets the mail it looks nice, really you have to think about how you want it to look and then format it that way. Link to comment https://forums.phpfreaks.com/topic/210363-on-my-email-script/#findComment-1097748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.