golfies Posted May 23, 2010 Share Posted May 23, 2010 Hello, I am really quite stuck with some code I wrote, This is my page www.bryansmusicbox.co.uk - I have saved the main page as index.php, If you enter data into the form, and click send, you get error 500. This is the code from index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Bryans Music Box</title> <link href="twoColFixRtHdr.css" rel="stylesheet" type="text/css" /><!--[if IE 5]> <style type="text/css"> /* place css box model fixes for IE 5* in this conditional comment */ .twoColFixRtHdr #sidebar1 { width: 220px; } </style> <![endif]--><!--[if IE]> <style type="text/css"> .twoColFixRtHdr #sidebar1 { padding-top: 30px; } .twoColFixRtHdr #mainContent { zoom: 1; } </style> <![endif]--> <link href="MM_DWCS4/MM_DWCS4/Chapter09/css/global.css" rel="stylesheet" type="text/css" /> </head> <body class="twoColFixRtHdr"> <div id="container"> <div id="header"> <p><img src="bryansheaderwords.jpg" width="533" height="73" /></p> <!-- end #header --> <ul class="MenuBarHorizontal"> <li><a href="index.html">Home</a></li> <li><a href="Music.html">Music</a></li> <li><a class="MenuBarItemSubmenu" href="crooners.html">Example Playlist</a></li> </ul> </div> <div id="sidebar1"> <h2> </h2> <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> </div> <div id="mainContent"> <h1><strong>Welcome </strong>to Bryans music box </h1> <h2>A varied vocalist</h2> <p class="tagline"> I sing a variety of songs which are from every decade from the fifties to present day. Song information can be seen on the list of songs I have compiled. Every generation seems to prefer songs which were popular for their day - songs which they are familiar with, songs that they can sing along to, and songs that uplift, inspire and hopefully bring back happy memories. </p> <p class="tagline"><img src="Brian.jpg" width="280" height="253" class="fltlft" /></p> <h2>Retirement Homes</h2> <p class="tagline"> An example of this is when entertaining in a retirement home I sing songs by crooners such as Frank Sinatra, Dean Martin, Matt Monro, Engelbert Humperdinck, Bobby Darin, Tony Bennett, Andy Williams and many more who were popular during the 40s, 50s and 60s. I provide all the equipment needed for each performance and use professionally high standard backing tracks. I have a wide range of vocal capabilities allowing me to sing and imitate a variety of singers. </p> <h2>Occasions</h2> <p class="tagline"> I am often requested to sing at ‘milestone’ birthdays (eg 80, 90, 100 year olds and older in some cases!) in care homes. If you are looking for a warm, friendly singer with a diverse singing talent to entertain your residents, look no further. Thank you for reading this letter and for your consideration,</p> </div> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" /> <div id="footer"> <div id="footerCol1"> <p><strong><br /> </strong></p> </div> <div id="FooterCol2"> <p> </p> </div> </div> <!-- end #container --></div> </body> </html> and here is my php script (which is where the problem lies...?) <?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"; ?> I have the php script saved onto the server as contact.php I hope one of you can help me, i will be VERY grateful, i cant begin to tell you how much i want this to work thanks in advance golfies < 3 Link to comment https://forums.phpfreaks.com/topic/202644-php-help-request-form-not-sending-data-to-email-account-why/ Share on other sites More sharing options...
kenrbnsn Posted May 23, 2010 Share Posted May 23, 2010 The next time you post code, please put it between tags like 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"; ?> See how much easier it is to read. If this is your code, you have a syntax error on the last line. The first "]" should be "[". Ken Link to comment https://forums.phpfreaks.com/topic/202644-php-help-request-form-not-sending-data-to-email-account-why/#findComment-1062219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.