Jump to content

Display form fields in email title


sphinx

Recommended Posts

Hi there,

 

I'm trying to output the form data into the email title, how I've attempted to do this is below:

 

<?php
if(isset($_POST['submit'])) {
   $to = '[email protected]' ;  
   $subject = '$song - $message - $name;  //THIS BIT HERE I NEED WORKING...
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "<table>
               <tr><td>Name</td><td>".$_POST['name']."</td></tr>
               <tr><td>Message</td><td>".$_POST['message']."</td></tr>
               <tr><td>Song</td><td>".$_POST['song']."</td></tr>

               </tr></table>" ;
   mail($to, $subject, $message, $headers);
   header('Location: song-requests-success.php');
}
?>

 

I keep getting errors.

 

Many thanks

Link to comment
https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/
Share on other sites

Variables aren't interpolated within single quoted strings, and the one below is missing a closing quote anyhow.

 

 $subject = '$song - $message - $name;  //THIS BIT HERE I NEED WORKING...

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.