Footnote:
ArkiePrince
Semi-Retired
See Blog


Valid XHTML 1.0
Valid CSS

PHP Feedback Form with Source Code

Tutorial For Feedback, Bug Report, Contact,etc. PHP Forms

VIP Feature: Since register_globals now are OFF by default, output file converts variables to Superglobals. And a new 'filter' blocks users (spammers) that try to send hot links (URL)

Other Features: Checks email 'format' validation - checks for the "@" and . (period). Also checks for required fields

This PHP - HTML - CSS template generated feedback form includes source code that makes it easy for users to create their own form. In effect, this functional feedback form is also a full form tutorial. By using the 'body' 'source code' displayed on the bottom of this page - along with the code generators from this web site, it's easy to create a profession feedback, bug report, etc form for your web site. In addition to form input and textarea, the form tutorial includes radio button and checkbox functions.

Additional tutorials for php forms are found at:

Bottom Line: This is a PHP feedback form for the maketemplate.com website and at the same time it's a php feedback, bug report, etc form tutorial (displaying all the php form source code at the bottom of page).

Feedback Form

All fields required:

Send Data to:
Name: Email:

Overall Rating: [ Good]   [ Bad]   [ Ugly]

Request additional features for a feedback tutorial:
Email 'format' Validation - check @
Required Form Field Validation.
More intergratd HTML (in form).
Improved PHP form script generator.
A complete HTML form generator.

General Comments



Feedback Form Code / Instructions

The source code for the two files (feedback.php and feedout.php) is shown below. Copy and paste the feedback.php into your existing php page. Then copy and paste the output and Thank You page into your existing Thank You page / template.
BTW: In the feedout.php file you must enter your 'from' and 'to' email address information.
VIP: The web host must have PHP safe mode OFF and the mail() function is required.
If not sure about Safe Mood, BE SURE to make and run a test.php (see notes)

feedback.php

<form action="feedout.php" method="post">
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<h2 align="center">Feedback Form</h2>
<p>
All input is blah blah ...... </p>
<p>Send Data to: <select name="attn" size="1">
<option value=" MT General Email ">General Email</option>
<option value=" MakeTemplate Owner ">Owner of MakeTemplate</option>
<option value=" Technical Support ">Technical Support</option>
<option value=" PHP Codemaster ">PHP Codemaster</option>
</select>
<br />
Name: <input type="text" name="nameis" size="20" /> Email:<input type="text" name="visitormail" size="20" />


<br/> Overall Rating:<br/> [<input checked="checked" name="rating" type="radio" value="good" /> Good]   [<input name="rating" type="radio" value="bad" /> Bad]   [<input name="rating" type="radio" value="ugly" /> Ugly]
</p>
<p> Request additional features for a feedback tutorial:<br />
<input type="checkbox" name="emailvalidation" value="y" /> Email 'format' Validation - check @<br />
<input type="checkbox" name="fieldvalidation" value="y" /> Required Form Field Validation.<br />
<input type="checkbox" name="htmlcontrol" value="y" /> More intergratd HTML (in form).<br />
<input type="checkbox" name="phpform" value="y" /> Improved PHP form script generator.<br />
<input type="checkbox" name="htmlform" value="y" /> A complete HTML form generator. <br />
</p>
<br />
<h3 align="center">General Comments</h3>
<p align="center">
<textarea name="feedback" rows="6" cols="30">Notes n comments here</textarea>
</p>
<hr />
<p align="center">
<input type="submit" value="Submit Feedback" />
</p>
<p>
<a href="http://www.maketemplate.com/feedback/"> Feedback Source Code </a>
</p>
</form>

feedout.php

<h3 align="center">Thanks for your Feedback </h3>
<!-- VIP: change YourEmail to your real email -->

<?php

$ip = $_POST['ip'];
$httpagent = $_POST['httpagent'];
$httpref = $_POST['$httpref'];
$nameis = $_POST['nameis'];
$visitormail = $_POST['visitormail'];
$feedback = $_POST['feedback'];
$rating = $_POST['rating'];
$emailvalidation = $_POST['emailvalidation'];
$fieldvalidation = $_POST['fieldvalidation'];
$htmlcontrol= $_POST['htmlcontrol'];
$phpform = $_POST['phpform'];
$htmlform = $_POST['htmlform'];
$attn = $_POST['attn'];

if (eregi('http:', $feedback)) { die ("Do NOT try that! ! "); }

if((!$visitormail == "") && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$tellem = "<h2>Feedback was NOT submitted</h2>\n";
}

if(empty($nameis) || empty($feedback) || empty($visitormail)) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

echo $tellem;

if ($emailvalidation == "y") {
$req1 = "Email format Validation \n" ;
}

if ($fieldvalidation == "y") {
$req2 = "Required Form Field Validation \n";
}
if ($htmlcontrol == "y") {
$req3 = "More intergratd HTML (in form) \n";
}
if ($phpform == "y") {
$req4 = "Improved PHP form script generator \n";
}
if ($htmlform == "y") {
$req5 = "A complete HTML form generator \n";
}
$req = $req1 . $req2 . $req3 . $req4 . $req5;

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn;
$subject = $attn;

$feedback = stripcslashes($feedback);

$message = " $todayis [EST] \n
Attention: $attn (Rating: $rating) \n
From: $nameis ($visitormail)\n
Requested:
$req \n
Feedback: $feedback \n
Additional Info : IP = $ip \n
Browser = $httpagent \n
Referral = $httpref
";

$from = "From: $visitormail\r\n";

mail("YourEmail", $subject, $message, $from);


$screenout = str_replace("\n", "<br/>", $message);
?>


<p align="center">

<?php echo $screenout ?>

</p>


Note: Some web host block the mail() function if the 'YourEmail' does not have your domain. In other words: sometimes, the domain email address must be used - or the mail() function will not work.


Check Safe Mode.

How to check that PHP is running and that Safe Mode is OFF !

Use notepad (or other text editor) create an ASCII text file with this line:

<?php phpinfo() ?>

Save that file as test.php
Must be a text file with .php extension - NOT test.php.txt

>Upload test.php (as ASCII file) - to the server

Run test.php from the browser
e.g. www.domain.com/test.php

This will display all the php settings. Use 'find' to check the 'safe' mode section to make sure it is OFF. e.g. look under the Configuration PHP Core Table in the Directive column to see that safe mode is off.


Sample code - converts form variables to Superglobals (for all forms):

<?php
$ip = $_POST['ip'];
$httpagent = $_POST['httpagent'];
$httpref = $_POST['$httpref'];
$nameis = $_POST['nameis'];
$visitormail = $_POST['visitormail'];
$feedback = $_POST['feedback'];
$rating = $_POST['rating'];
$emailvalidation = $_POST['emailvalidation'];
$fieldvalidation = $_POST['fieldvalidation'];
$htmlcontrol= $_POST['htmlcontrol'];
$phpform = $_POST['phpform'];
$htmlform = $_POST['htmlform'];
$attn = $_POST['attn'];
?>