golfies Posted May 14, 2010 Share Posted May 14, 2010 I am new here and would greatly appreciate a response, I am at my wits end with this problem.... I recently created a website which can be found here: www.bryansmusicbox.co.uk I have got a form.. however I cannot forward this data to my email box, it is very frustrating, I have tried dreamweavers Mail2form extension to no sucess, here is my form data on my index.HTML page <form action="contact.php" method="post" name="question" id="question" accept-charset="iso-8859-1"> <p> <label for="questName">Your Name</label> <input name="questName" type="text" id="questName" size="20" /> </p> <p> <label for="questEmail"> Your Email</label> <input name="questEmail" type="text" id="questEmail" size="20" /> </p> <p> <label for="question">Venue, How many residents/guests/occasion</label> <textarea name="question2" cols="20" rows="5"></textarea> </p> <p> <input type="submit" name="submitQuestion" id="submitQuestion" value="Make a Booking now" /> </p> <input type="hidden" name="hdwemail" id="hdwemail" value="bryan.flood+bryansmusicbox.co.uk" /> </form> and here is my PHP page <?php $to = "[email protected]"; $subject = "Contact Us"; $questName = $_REQUEST['questName'] ; $questEmail = $_REQUEST['questEmail'] ; $question2 = $_REQUEST['question2'] ; $headers = "From: [email protected]"; $sent = mail($questName, $subject, $questEmail, $question2) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } $fields = array(); $fields{"questName"} = "questName"; $fields{"questEmail"} = "questEmail"; $fields{"question2"} = "question2"; ?> PHP is enabled on the server and after clicking submit i do recieve an email sometimes, but its from an unknown sender and has no data in in ! A prompt response would be appreciated and i will try to help at least three other members if i get a reply thanks in advance Golfies Link to comment https://forums.phpfreaks.com/topic/201694-php-data-forwarding-in-form-help-request/ Share on other sites More sharing options...
cags Posted May 14, 2010 Share Posted May 14, 2010 The first parameter of the mail function expects a target e-mail address, you are passing it the persons name, the third parameter should be the main body of the e-mail and you are sending it the e-mail, the 4th parameter is for e-mail headers and you are passing it the actual question. Link to comment https://forums.phpfreaks.com/topic/201694-php-data-forwarding-in-form-help-request/#findComment-1058160 Share on other sites More sharing options...
golfies Posted May 15, 2010 Author Share Posted May 15, 2010 which bit is the function? The bit above the array? Could you give an example of what to replace with what so i know where to work from? $to = "[email protected]"; $subject = "Contact Us"; $questName = $_REQUEST['questName'] ; $questEmail = $_REQUEST['questEmail'] ; $question2 = $_REQUEST['question2'] ; is this the fubction? I do i need to replace the first parts of these? Again help appreciated <3 Link to comment https://forums.phpfreaks.com/topic/201694-php-data-forwarding-in-form-help-request/#findComment-1058571 Share on other sites More sharing options...
kenrbnsn Posted May 15, 2010 Share Posted May 15, 2010 The mail function has defined parameters: <?php mail($to, $subject, $body, $headers, $extra_header); ?> You MUST use the parameters properly or the mail() function won't work. The "extra_header" parameter is optional. Try this: <?php $to = "[email protected]"; $subject = "Contact Us"; $questName = $_REQUEST['questName'] ; $questEmail = $_REQUEST['questEmail'] ; $question2 = $_REQUEST['question2'] ; $body = array(); $body[] = 'QuestName: ' . $_POST['questName']; $body[] = 'QuestEmail: ' . $_POST['questEmail']; $body[] = 'Question2: ' . $_POST['question2']; $headers = "From: Bryan Flood <[email protected]>"; $sent = mail($to, $subject, implode("\n",$body), $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } $fields = array(); $fields["questName"] = "questName"; $fields["questEmail"] = "questEmail"; $fields]"question2"] = "question2"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/201694-php-data-forwarding-in-form-help-request/#findComment-1058603 Share on other sites More sharing options...
golfies Posted May 17, 2010 Author Share Posted May 17, 2010 Using kens code, i still get the server error, check it out on www.bryansmusicbox.co.uk do you think it could be my form? :S or perhaps that my index page is a .html and not a .php? This is my form code : <form action="contact.php" method="post" name="question" id="question" accept-charset="iso-8859-1"> <p> <label for="questName">Your Name</label> <input name="questName" type="text" id="questName" size="20" /> </p> <p> <label for="questEmail"> Your Email</label> <input name="questEmail" type="text" id="questEmail" size="20" /> </p> <p> <label for="question">Venue, How many residents/guests/occasion</label> <textarea name="question2" cols="20" rows="5"></textarea> </p> <p> <input type="submit" name="submitQuestion" id="submitQuestion" value="Make a Booking now" /> </p> <input type="hidden" name="hdwemail" id="hdwemail" value="bryan.flood+bryansmusicbox.co.uk" /> </form> help please I will be very appreciative as I cannot do this for toffee (i really like toffee) Link to comment https://forums.phpfreaks.com/topic/201694-php-data-forwarding-in-form-help-request/#findComment-1059595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.