chriss1986 Posted March 5, 2009 Share Posted March 5, 2009 Hi guys, first time poster - be gentle!!! I am really stuck, I have no experience with writing .html or .php scripts, but with the help of Dreamweaver, Google and some existing pages from my company website, I have been able to put some pages together. I want now to set up an .html form for a customer survey, and a .php script to email the data collected to a predetermined email address. I can generate the mail, but it doesn't seem to record the options that were entered on the form. I am also getting .php errors after submitting the web form. Here is a sample of a question on the .html page: <form action="CustomerSurvey.php" method="post" name="form1" class="introcopy"> <label for="Name"> <div align="left">Name:</div> </label> <div align="left"> <input type="text" name="Name" id="Name"> </div> > <label for="Company"> <div align="left">Company:</div> </label> <div align="left"> <input type="text" name="Company" id="Company"> </div> <label for="Email"> <div align="left">Email Address:</div> </label> <div align="left"> <input type="text" name="Email" id="Email"> </div> <label for="CContact Points"> <div align="left"><br> <label for="Contact Points"><br> <span class="bodycopy">Please think about your dealings with ********** before selecting the most relevant statemnets to the following questions:</span><br> <br> <br> My Contact Points Within ************ are clearly defined and easy to access.</label> <p> <select name="Contact Points" id="Contact Points" <option selected> </option> <option value="Strongly Disagree">Strongly Disagree</option> <option value="Disagree Somewhat">Disagree Somwhat</option> <option value="Neutral">Neutral</option> <option value="Agree Somewhat">Agree Somwhat</option> <option value"Agree Strongly">Agree Strongly</option> </select> </p> Here is the .php script in it's entirity: <?php $to = "online.support@********.co.uk" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['Name'] ; $headers = "From: $from"; $subject = "Customer Survey Submission"; $fields = array(); $fields{"Name"} = "Name"; $fields{"Company"} = "Company"; $fields{"Email"} = "Email"; $fields{"Contact Points"} = "Contact Points"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: noreply@*******.co.uk"; $subject2 = "Thank you for your response"; $autoreply = "Thank you for responding to our customer survey. ********* will donate £5 to Breast Cancer Research on your behalf."; } } ?> I have taken most of these scripts from existing ones on our web site that work, but these don't seem to..... After you guys finish laughing at my attempts I would love some help as to where I'm going wrong. Thanking you in advance! Link to comment https://forums.phpfreaks.com/topic/148122-php-code-to-email-html-form-results/ Share on other sites More sharing options...
ScotDiddle Posted March 5, 2009 Share Posted March 5, 2009 chriss1986, I've been coding since 1979 (Mainframes back then) and it is still all about the tools... In photo 1 below, you will see that Zend Studio 5.5.0 immediately determined that you are missing a closing greater-than character at the end of your select statement "id="Contact Points", and that you are missing an equal sign in <option value"Agree Strongly">Agree Strongly</option> Photo 2 created with Zend Studio 5.5.0 shows superfluous closing brackets at the end of your "CustomerSurvey.php" script. Photo 3 show the same errors as photo 1, but it doesn't point to the errors right away, because "Free" IDE's ( Integrated Development Environments ) like Notepad++ are not as smart as a real debugger / syntax highlighter. ( Note in this photo that <option value"Agree Strongly">Agree Strongly</option> picked up on the missing equal sign, but the missing select close greater-than char. higher up error is a lot harder to spot. ) Granted, IDE's are expensive, but the time saved by using a good tool instead of trying to debug by yourself will make up the cost in increased productivity many times over. (Edit... Note that color-highlighting in photo 3 makes it easy to spot the extra > sign just below your </div> statement ) Scot L. Diddle, Richmond VA Photo 1 : Photo 2 : Photo 3: Link to comment https://forums.phpfreaks.com/topic/148122-php-code-to-email-html-form-results/#findComment-777572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.