OrganikComp Posted December 16, 2007 Share Posted December 16, 2007 Hey everyone, I'm terrible at PHP and need help quick I have a website and part of it is a function where people fill out a survey and click submit so their answers are emailed to me My old way of them filling out the survey was to send them to a third party but recently i decided to do some coding myself mostly using tutorials and other people for help heres the code <html> <head> <title></title> </head> <?php $hello = $_POST['one']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question One'; mail($myemail, $subject, $hello); ?> <?php $hello = $_POST['two']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question Two'; mail($myemail, $subject, $hello); ?> <?php $hello = $_POST['three']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question Three'; mail($myemail, $subject, $hello); ?> <?php $hello = $_POST['four']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question Four'; mail($myemail, $subject, $hello); ?> </body> </html> It sends me four separate emails containing a single answer thats in correspondance to the POST question Can anyone give me a code so i can incorporate all the questions but get every single answer in a single email instead of the way it is working currently Someone suggested a loop but i'm not sure how to do that or if it will work Thanks for the help Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 <html> <head> <title></title> </head> <?php $hello = $_POST['one']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question'; $message = $_POST['one'] . "\n" $_POST['two'] . "\n" . $_POST['three'] . "\n" . $_POST['four']; mail($myemail, $subject, $message); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
OrganikComp Posted December 16, 2007 Author Share Posted December 16, 2007 got some unexpected T_VARIABLE error on line 10 fixable??? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 16, 2007 Share Posted December 16, 2007 Need a period before $_POST['two'] and you'll probably get a mail error saying invalid From:, since you should have that included in the mail() function, unless you have it set in your PHP.INI. Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 oops i forgot to enter the period, here it is with the period <html> <head> <title></title> </head> <body> <?php $hello = $_POST['one']; $myemail = 'organikcomputers@yahoo.com'; $subject = 'Question'; $message = $_POST['one'] . "\n" $_POST['two'] . "\n" . $_POST['three'] . "\n" . $_POST['four']; mail($myemail, $subject, $message); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
OrganikComp Posted December 16, 2007 Author Share Posted December 16, 2007 never mind i figured it out there was a period missing Quote Link to comment Share on other sites More sharing options...
OrganikComp Posted December 16, 2007 Author Share Posted December 16, 2007 Thank you very much northern flame you're amazing 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.