AdamLewis Posted April 13, 2014 Share Posted April 13, 2014 My code does everything it is supposed to, but within the body of the email I receive is just "My name is $name.$from$email$message" Here is the PHP code that I'm working with (obviously I've changed the email address for this purpose): <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Your Website'; $to = 'example@hotmail.co.uk'; $subject = 'message.'; $message = 'My name is $name.$from$email$message';if ($_POST['submit']) { mail($to, $subject, $message); $feedback = 'Thank you, your message has been sent.';}?> Working with the HTML: <p id="feedback"><?php echo $feedback; ?></p><form method="post" action="contact.php"> <label for="name">Name</label> <input id="name" name="name" placeholder="Type Here"> <label for="email">Email</label> <input id="email" name="email" type="email" placeholder="Type Here"> <label for="message">Message</label> <textarea name="message" placeholder="Type Here"></textarea> <input id="submit" name="submit" type="submit" value="Submit"> </form> Thanks for your help in advance. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 13, 2014 Share Posted April 13, 2014 Only the $name variable? I believe not http://www.php.net/manual/en/language.types.string.php Quote Link to comment Share on other sites More sharing options...
AdamLewis Posted April 13, 2014 Author Share Posted April 13, 2014 I'm sorry, I don't really understand what you mean by 'only the name variable.' The message I receive is: My name is $name.$from$email$message Quote Link to comment Share on other sites More sharing options...
AdamLewis Posted April 13, 2014 Author Share Posted April 13, 2014 But thank you for the link, it helped me to fix it by adding " instead of ' Quote Link to comment Share on other sites More sharing options...
Solution jazzman1 Posted April 13, 2014 Solution Share Posted April 13, 2014 When the php parser encountered a string enclosed in single quotes in the php document, it treats variables and any others spacial symbols like \n,&,|| and so on...as a literal text.In your example above not only the value of $name will be escaped but $from,$email,$message as well. Quote Link to comment 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.