Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.