kelharis Posted March 7, 2009 Share Posted March 7, 2009 Hello everyone, I am creating a short little form that will email the submitted information to someone using MS Outlook mail. I have tested my code and it will email the correct email, email the correct subject, but I have an error somewhere in the "message" section. I have probably just made some idiotic mistake as usual, but I can't find it. here is the code, the message in the email just reads as the variable $message is written, i.e. "$name /n $email /n $school /n $diet" Where am I going wrong? <?php $name = $_REQUEST ['name'] ; $email = $_REQUEST['email'] ; $school = $_REQUEST['school'] ; $diet = $_REQUEST['diet'] ; $message = '$name /n $email /n $school /n $diet'; mail( "XXXXXXXXX", "Subject: Leadership Seminar Signup", $message, "From: $email" ); //if "email" is not filled out, display the form echo "<center><form method='post' action='pages/leadershipform.php'> Name: <input name='name' type='text' /><br /> Email: <input name='email' type='text' /><br /> School: <input name='school' type='text' /><br /> Special Dietary Needs: <input name='diet' type='text' /> <br /> <input type='submit' /> </form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/148307-trying-to-mail-a-submitted-form/ Share on other sites More sharing options...
redarrow Posted March 7, 2009 Share Posted March 7, 2009 sorry re edited <?php $name="redarrow"; $email="redarrow@redarrow.com"; $school="phpfreaks"; $diet="fat lol!"; $message1 = "$name \n $email \n $school \n $diet"; $message2 = ' '.$name.' \n '.$email.' \n '.$school.' \n '.$diet.' '; echo "$message2 <br><br> $message2"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/148307-trying-to-mail-a-submitted-form/#findComment-778631 Share on other sites More sharing options...
Philip Posted March 7, 2009 Share Posted March 7, 2009 When variables and other certain values (like \n) are in single quotes they will not be parsed, just read how you see them. In other words, $message = '$name /n $email /n $school /n $diet'; should be: $message = :"$name /n $email /n $school /n $diet"; Quote Link to comment https://forums.phpfreaks.com/topic/148307-trying-to-mail-a-submitted-form/#findComment-778764 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.