steven21 Posted March 7, 2006 Share Posted March 7, 2006 I have got some code for a basic feedback form which asks for the users name and email and there comments, and this works, but I want to add a list option where the user choose from a list of options, things is I am not sure how to amend the php code. i have tried what I thought would have worked but it didn work. can anyone advise me of what i need to add the code I currently have (below) so i can add the list option into the feedback formthanks[code]// ------------- CONFIGURABLE SECTION ------------------------// $mailto - set to the email address you want the form// sent to, eg//$mailto = "youremailaddress@example.com";$mailto = 'me@myemail.com';// $subject - set to the Subject line of the email, eg//$subject = "Feedback Form";$subject = "MyWorld21.co.uk Feedback";// the pages to be displayed, eg//$formurl = "http://www.example.com/feedback.html";//$errorurl = "http://www.example.com/error.html";//$thankyouurl = "http://www.example.com/thankyou.html";$formurl = "http://www.myworld21.co.uk/newsite/contact.html";$errorurl = "http://www.myworld21.co.uk/newsite/error.html";$thankyouurl = "http://www.myworld21.co.uk/newsite/thankyou.html";$uself = 1;// -------------------- END OF CONFIGURABLE SECTION ---------------$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n";$name = $_POST['name'];$email = $_POST['email'];$comments = $_POST['comments'];$http_referrer = getenv( "HTTP_REFERER" );if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit;}if (empty($name) || empty($email) || empty($comments)) { header( "Location: $errorurl" ); exit;}if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit;}if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments );}$messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $name\n" . "Email of sender: $email\n" . "" "------------------------- USER COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n";mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );header( "Location: $thankyouurl" );exit; [/code] Quote Link to comment Share on other sites More sharing options...
steven21 Posted March 8, 2006 Author Share Posted March 8, 2006 can anyone help me wit this? Quote Link to comment Share on other sites More sharing options...
steven21 Posted March 13, 2006 Author Share Posted March 13, 2006 :( can no one help with this? Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted March 14, 2006 Share Posted March 14, 2006 What exactly are you trying to do? Add a drop down list to your form and have the option selected emailed in your form?What did you try that didn't work? Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted March 14, 2006 Share Posted March 14, 2006 Here is a snippet from one of my forms:[code] <tr> <td class="form">Relationship:</td> <td class="form"><select name="status"> <option value="FA">Family <option value="FR">Friend <option value="BU">Employer <option value="OT">Other </select></td> <td class="form">Please select one option </td> </tr>[/code]When that form submits, the form processor has this code to interpret the form data that was submitted:[code]$status = $_POST['status'];if (!$status) {echo '<center><h1>You did not submit the following required information!</h1></center><br />'; if(!$status){ echo "Relationship is a required field. Please enter it below.<br />"; }[/code]I have an email function setup as well, setup my headers:[code]$headers = "MIME-Version: 1.0\n";$headers .= "Content-type: text/html; charset=iso-8859-1\n";$headers .= "From: $sender\n";[/code]And then I add my data to an array first.[code]$send = array ( 'status' => $status, );[/code]And then I setup the body of the mail message:[code]$body = "Status: ".$send['status'];[/code]And then I send the message:[code]mail ("yourname@yourdomain.com" , $subject, $body, $headers);[/code] 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.