Jump to content

on my email script


nouse4one

Recommended Posts

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

<?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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.