Revision [754]
This is an old revision of FeedbackAction made by DarTar on 2004-07-18 19:57:17.
Feedback Action
This action displays a form for sending user feedback to the site administrator email, as specified in wakka.config.php.
It first validates the form, then sends it using the mail() function and displays a "thanks for your feedback"message
To use it you will first need to save the code below in a file called feedback.php in the actions folder.
Then simply add {{feedback}} in the page in which you want the feedback form to be displayed.
-- DarTar
<?php
$form = '<p>Fill in the form below to send us your comments:</p>
<form method="post" action="SendFeedback?mail=result">
Name: <input name="name" value="'.$_POST["name"].'"type="text" /><br />
Email: <input name="email" value="'.$_POST["email"].'" type="text" /><br />
Comments:<br />
<textarea name="comments" rows="15" cols="40">'.$_POST["comments"].'</textarea><br />
<input type="submit" />
</form>';
if ($_GET["mail"]=="result") {
$name = $_POST["name"];
$email = $_POST["email"];
$comments = $_POST["comments"];
if (!$name) {
// a valid name must be entered
echo "<p class=\"error\">Please enter your name</p>";
echo $form;
} elseif (!$email || !strchr($email, "@")) {
// a valid email address must be entered
echo "<p class=\"error\">Please enter a valid email address</p>";
echo $form;
} elseif (!$comments) {
// some text must be entered
echo "<p class=\"error\">Please enter some text</p>";
echo $alert;
echo $form;
} else {
// send email and display message
$msg = "Name:\t".$name."\n";
$msg .= "Email:\t".$email."\n";
$msg .= "Comments:".$comments."\n";
$recipient = $this->GetConfigValue("admin_email");
$subject = "Feedback from ".$this->GetConfigValue("wakka_name");
$mailheaders = "From:".$email."\n";
$mailheaders .= "Reply-To:".$email."\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo $this->Format("Thanks for your interest! Your feedback has been sent to [[".$recipient."]] ---");
echo $this->Format("Return to the [[".$this->GetConfigValue("root_page")." main page]]");
// optionally displays the feedback text
//echo $this->Format("---- **Name:** ".$name."---**Email:** ".$email."---**Comments:** ---".$comments);
}
} else {
echo $form;
}
?>
$form = '<p>Fill in the form below to send us your comments:</p>
<form method="post" action="SendFeedback?mail=result">
Name: <input name="name" value="'.$_POST["name"].'"type="text" /><br />
Email: <input name="email" value="'.$_POST["email"].'" type="text" /><br />
Comments:<br />
<textarea name="comments" rows="15" cols="40">'.$_POST["comments"].'</textarea><br />
<input type="submit" />
</form>';
if ($_GET["mail"]=="result") {
$name = $_POST["name"];
$email = $_POST["email"];
$comments = $_POST["comments"];
if (!$name) {
// a valid name must be entered
echo "<p class=\"error\">Please enter your name</p>";
echo $form;
} elseif (!$email || !strchr($email, "@")) {
// a valid email address must be entered
echo "<p class=\"error\">Please enter a valid email address</p>";
echo $form;
} elseif (!$comments) {
// some text must be entered
echo "<p class=\"error\">Please enter some text</p>";
echo $alert;
echo $form;
} else {
// send email and display message
$msg = "Name:\t".$name."\n";
$msg .= "Email:\t".$email."\n";
$msg .= "Comments:".$comments."\n";
$recipient = $this->GetConfigValue("admin_email");
$subject = "Feedback from ".$this->GetConfigValue("wakka_name");
$mailheaders = "From:".$email."\n";
$mailheaders .= "Reply-To:".$email."\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo $this->Format("Thanks for your interest! Your feedback has been sent to [[".$recipient."]] ---");
echo $this->Format("Return to the [[".$this->GetConfigValue("root_page")." main page]]");
// optionally displays the feedback text
//echo $this->Format("---- **Name:** ".$name."---**Email:** ".$email."---**Comments:** ---".$comments);
}
} else {
echo $form;
}
?>