Jump to content


Photo

feedback forms


  • Please log in to reply
4 replies to this topic

#1 steven21

steven21
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationCentral Scotland

Posted 07 March 2006 - 09:35 PM

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

thanks

// ------------- 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;


#2 steven21

steven21
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationCentral Scotland

Posted 08 March 2006 - 12:09 AM

can anyone help me wit this?

#3 steven21

steven21
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationCentral Scotland

Posted 13 March 2006 - 12:43 PM

:( can no one help with this?

#4 tsiedsma

tsiedsma
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 14 March 2006 - 08:40 PM

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?

#5 tsiedsma

tsiedsma
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 14 March 2006 - 08:52 PM

Here is a snippet from one of my forms:
        <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>

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 />';
    if(!$status){
        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);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users