Jump to content


This topic is now archived and is closed to further replies.


feedback forms

Recommended Posts

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 form


[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" );
if (empty($name) || empty($email) || empty($comments)) {
   header( "Location: $errorurl" );
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
    header( "Location: $errorurl" );

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 .

mail($mailto, $subject, $messageproper,
    "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit; [/code]

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites
Here is a snippet from one of my forms:
          <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
          <td class="form">Please select one option </td>

When that form submits, the form processor has this code to interpret the form data that was submitted:

$status = $_POST['status'];

if (!$status) {
echo '<center><h1>You did not submit the following required information!</h1></center><br />';
        echo "Relationship is a required field. Please enter it below.<br />";

I have an email function setup as well, setup my headers:
$headers  = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $sender\n";
And then I add my data to an array first.
$send = array (
    'status'    => $status,
And then I setup the body of the mail message:
$body  = "Status: ".$send['status'];
And then I send the message:
mail ("yourname@yourdomain.com" , $subject, $body, $headers);

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.