Jump to content

feedback forms


steven21

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

thanks

[code]// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto        = "[email protected]";

$mailto = '[email protected]';

// $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]
Link to comment
https://forums.phpfreaks.com/topic/4367-feedback-forms/
Share on other sites

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 ("[email protected]" , $subject, $body, $headers);
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4367-feedback-forms/#findComment-17516
Share on other sites

Archived

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

×
×
  • Create New...

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.