sphinx Posted October 16, 2011 Share Posted October 16, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/ Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2011 Share Posted October 16, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279779 Share on other sites More sharing options...
sphinx Posted October 16, 2011 Author Share Posted October 16, 2011 when i quoted it at end, i didnt get an error, but email title was '$song - $message - $name' Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279781 Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2011 Share Posted October 16, 2011 Variables aren't interpolated within single quoted strings. Use double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279785 Share on other sites More sharing options...
sphinx Posted October 16, 2011 Author Share Posted October 16, 2011 when i try both: $subject = "$song" - "$message" - "$name"; and $subject = "$song - $message - $name"; I don't get an error, and the email title is blank just with "-" Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279789 Share on other sites More sharing options...
Pikachu2000 Posted October 16, 2011 Share Posted October 16, 2011 Where are those variables defined? I don't see anywhere in the code where they're given values. Are you sure you didn't mean to use $_POST['song'], etc.? Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279791 Share on other sites More sharing options...
sphinx Posted October 16, 2011 Author Share Posted October 16, 2011 sorry i dont know what you mean? when an email comes through the details work, i just cant get it in the title Quote Link to comment https://forums.phpfreaks.com/topic/249221-display-form-fields-in-email-title/#findComment-1279802 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.