Comprehensive Feedback Form with Attachments
You know that spam harvesters are able to take e-mails from websites if they are just coded in standard HTML. You could encode your email as I’ve described earlier. But a feedback form is the best approach.
The most of feedback forms allow them to enter their name, email and type a message. Sometime you may need to send an attached file (a photo, a screenshot…).
This Feedback-Form script provides you with an option to send an attached file with the form message.
Download: feedback-form.zip
How to install this script
Note. PHP support at your hosting is required.
1) Download the feedback-form.zip file.
2) Unzip it with subdirectories at your local PC.

3) Open the config.php file ( 1 ) with an ASCII-text editor (i.e. Notepad)

4) Adjust this variables with appropriate values: $site_name ( 6 ) - the name of your site. It would be used inside the form title.
$support_email ( 7 ) - your email address to receive the form messages to.
You also can edit the $support_subject ( 8 ) and $support_message ( 9 ) variables to change the message Subject and Body.
5) Save the changed config.php file and upload all files with subdirectories onto your site.
6) Change the permissions of the tmp folder ( 2 ) to 777. (CHMOD 0777 tmp)
That’s all.
Place a link to feedback.php ( 3 ) on your site’s pages.
<a href="http://YouSite.com/feedback.php">Feedback</a>
If you’d like you can change the pages templates ( 5 ) with any HTML-editor. The template.form.html file is the template of the form-page. The template.thankyou.html file is the template of the thank-you page which appears after the form submitted.
Anti Form-Spam feature
(was added Jan 27, 2007)
The Anti Form-Spam feature is based on a JavaScript execution inside browsers.
Make sure you uploaded the md5.js ( 4 ) file beside your form-page template and set the $anti_bot variable ( 10 ) value to 1.
Related Articles:







September 7th, 2006 at 20:28
How can one use this feedback form with your HTML to PHP template system. I tried to incorporate this feedback form into my template system but I cant get it to work…it works fine as a standalone system but not with my template system which is based on your HTML to PHP template system.
September 8th, 2006 at 05:11
Hi Gann,
You can use your own web-form with the
feedback.phpscript.Create a html-page with your form. Set the
action-attribute of yourformwith thefeedback.phpscript.Then include the form-page like you’ve included the footer:
——————————
$FOOTER_FILE = "footer.html";
$FORM_FILE = "form.html";
…
// show the FORM
readfile($FORM_FILE);
// show the Footer
readfile($FOOTER_FILE);
exit;
——————————
Web-Form for the feedback.php
Your
form.htmlfile could look like this:<script type="text/javascript"><!--
function checkForm(theForm) {
if ("" == theForm.first_name.value) {
alert("Please enter your First name");
theForm.first_name.focus();
return false;
}
if ("" == theForm.email.value) {
alert("Please enter your Email");
theForm.email.focus();
return false;
}
return true;
}
//-->
</script>
<form action="feedback.php" method="post"
enctype="multipart/form-data"
onSubmit="return checkForm(this);">
<table width="500" align="center" border="0">
<tr>
<td>Feedback</td>
</tr>
<tr>
<td>
<table>
<tr>
<td><nobr><b>Your First Name</b></nobr></td>
<td><input name="first_name" /></td>
</tr>
<tr>
<td><nobr><b>Your Last Name</b></nobr></td>
<td><input name="last_name" /></td>
</tr>
<tr>
<td><nobr><b>Your Email address</b></nobr></td>
<td><input name="email" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr valign="top"><td><b>Comment</b></td>
<td><textarea name="message" cols="40">
</textarea></td>
</tr>
<tr><td><b>Attachment</b></td>
<td><input type="file" name="file" /></td>
</tr>
<tr><td> </td>
<td><input type="submit"
value="Send Message" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
I hope this helps.
Michel
September 8th, 2006 at 05:57
awsome.
thanks michel,
September 14th, 2006 at 19:39
After using this method, I dont get the thankyou page after sending message.
September 17th, 2006 at 11:03
Hi Gann,
Did you uploaded the
template.thankyou.htmlfile with thefeedback.phpscript?Could you let me the link of your directory?
Michel
September 18th, 2006 at 16:47
Yes, I did upload the template.thankyou.html file. If I use the form example as shown here, I get the form again after sending email. But I also did notice the email was NOT sent.
Secondly, if I use the feedback.php directly for the form, it shows the code that is at the end of the code in the feedback.php file.
I could give you the link but I dont want to at this point because my site is not finished and I dont want any visitors to come to my site that might be reading this, until my site is ready. Can I send it privately to you in an email?
September 21st, 2006 at 17:57
First, I would like to thank you Michel for your help in trying to solve my previous problem. Much appreciated. I have a question concerning the line format of the received feedback email that is created using the feedback script. Where would I specify the line-format of the email that I receive using the feedback form. I want the emails to have a line format of about 65 characters wide…do I have to make a change inside the code of the feedback.php file? Thanks.
September 27th, 2006 at 15:45
Hi Jimmy,
I’ve uploaded new version of the Feedback script.
It allows you to format the message lines to 65 characters wide,
or whatever another wide.
You can set the lines-length with the “$wordwrap” config-variable:

I hope this helps.
Michel
PS. Please check your email-box.
I’ve sent the modified script to you.
September 27th, 2006 at 19:05
Thanks Michel. I am learning alot about PHP coding. You make it so simple to understand.
I have one last question that occured to me today…it concerns security. Does your feedback script contain a security feature that prevents others from using the feedback script installed on my site from another server? Spammers often use feedback forms on other servers to send spam.
Thanks,
Jimmy
September 28th, 2006 at 04:42
Hi Jimmy,
Yes! You’re right. I forgot about the forms vulnerability…
I’ve just added anti-spam security checking to the new version.
It prevents spam attacks through the
first_name,last_nameandemailfields.The new version is uploaded.
Michel
PS. The modified version has been sent to you.
November 21st, 2006 at 14:06
Hi Michel,
I really appreciate your code of feedback form that works pretty well. It seems that in the code you used ‘move_uploaded_file’ to uplaod attachment to the website, then attach it with email. Can email grabs attachment directly from user’s hard disk?
John
November 29th, 2006 at 18:49
Hi John,
Thanks for your question.
When a user submit a web-form with file-attachments their browser uploads the files onto the server (site). There isn’t any other way. Server can’t access to user’s hard disk.
The uploaded files are stored in the server temp folder. The script has to move or copy this files from the temp folder to be able to work with them.
This is why the ‘move_uploded_file’ PHP-function is used.
Michel
January 5th, 2007 at 14:10
I just installed your nifty feedback script…
… Assuming it’s not hacked by a spammer, it will top my list of the best feedback form I’ve tested (and I’ve tried a bunch).
I do have a request for you — it would be extremely helpful to add another field to automatically detect the HTTP Referer URI…
… For example, when someone writes something like:
I disagree with your opinion on the Iraq war — especially what you said in the second paragraph.
When this happens, I have to track down the feedback submitter and ask what webpage s/he’s referring to.
But by including the webpage URL, it saves me this step.
Even better, if your script could record other user information such as their browser software, IP address, screen size, operating system, and other easy to grab info, that would be helpful for helping troubleshoot problems with visitors to my site.
For example, if I saw this in my feedback:
Feedback:
I can’t see your website!
80.22.126.99
[80-22-126-99.dynamic.dsl.as9105.com]
United Kingdom
Internet Explorer
Agent String: Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 2.1; SV1; .NET CLR 1.1.4322)
I’d be able to analyze the data and suggest this user upgrade their operating system and browser software. Plus, I’d also suggest removing the NET CLR spyware — a quite malicious one at that by the way.
Do you like? Can you add this to your next upgrade?
Once again, great job Michel.
Cheers,
Markus Allen
Publisher
http://www.marketing-ideas.org
January 5th, 2007 at 18:41
Hi Markus,
Thanks for your comment.
You can try new version with IP, Geo info and browser parameters included.
Download the new pack with the same link feedback-form.zip
I hope this helps.
Michel
July 9th, 2007 at 22:58
[…] For the “Ask A Question” form, you can get a free script right here. As I said, this is great to bulk up the content section of a website. I use both “Ask A Question” and “Submit A Topic” on one of my websites. It’s essentially the same thing, but it really bulks my site up well. […]
August 14th, 2007 at 16:41
Hy Michel,
I really appreciate your code of feedback form that I have installed in a webpage that I am going to lunch.
I have copied the code and pasted inside this page http://www.companiadelaselva.com/page06a.php?menu=6
I followed the instruccions of the config.php
then upload everything but
pasted the code of the template.form.html into this page
http://www.companiadelaselva.com/page06a.php?menu=6
and changed the form action to
It works pretty well I have tested but I have two questions Please :
1.- How do I fix the error message in red I have over the message box ?
2.- How do I make invisible the {FIRST_NAME} - {LAST_NAME} - {EMAIL}
tags that appear in the field Name - Last Name and email ?
Hope I didnot made a terrible mistake!
Thank you in advance
Fernanda Estrada
August 15th, 2007 at 10:13
Hi Fernanda,
1) Remove the
{ERROR}tag from the code you’ve copied into your http://www.companiadelaselva.com/page06a.php?menu=6 page.2) Also remove the
{FIRST_NAME} - {LAST_NAME} - {EMAIL}tags from the<input >fields.This should help.
Michel
September 3rd, 2007 at 14:17
Hi, is there a reason the file attached is limited to 1MB? Was hoping to raise this to more like 3-5MB
Thanks
September 3rd, 2007 at 14:25
Is it possible to send attatchments of over 1MB?
September 4th, 2007 at 04:58
Hi Paul,
Yes, it’s possible to send attachments of over 1MB.
There isn’t an attachment size limitation in the form-script itself.
However there is a size-limit in the PHP-settings for your hosting.
Generally the limit for a shared hosting is set to 2MB.
If you need more, you have to adjust your PHP-settings.
Michel
September 6th, 2007 at 00:09
Hi Michel,
I sometimes have people that wish to submit more than one file at a time (at most 3), and I don’t want them to have them have to resubmit the form for each file. Would it be a simple process to add 2 more of the file attachment controls? I’m very new to PHP, so I’m not sure how I’d go about doing this. Thanks.
Ps. Great site and exceptional help.
October 8th, 2007 at 12:13
Hi Michel
I’m trying to use my form (order.html) with yr feedback.php … I’ve follow all yr instructions above.. except below:
Then include the form-page like you’ve included the footer:
——————————
$FOOTER_FILE = “footer.html”;
$FORM_FILE = “form.html”;
…
// show the FORM
readfile($FORM_FILE);
// show the Footer
readfile($FOOTER_FILE);
exit;
——————————
Which file I’m supposed to include abv command? feedback.php or config.php?
This is the form i’m working on:
http://www.handmadeceramictiles.com/order.html
tks in advance…
kor
p/s:
May 6th, 2008 at 08:04
hello,
I am using this script , but I cant recieve any email into my support mail. When I submit the form, it says that the comments successfully submitted, but I cant recive any email.
if anyone knows, Please help me i need it urgently
July 27th, 2008 at 14:46
Hey Michel,
Great site. I certainly got more than I asked for when I Googled “oto scripts”.
I just downloaded your script on Feedback Forms with attatchments. I quickly set up a test page and everything works great.
Thanks a bunch,
Jeff
December 12th, 2008 at 06:33
Hey Michel,
I just wanted to say a big thank you for creating the feedback form with very clear instructions & for allowing us less intelligent web creators to benefit from your skill in our own sites.
I understand the very basics of programming (I started out with BASIC on an old Acorn BBC, then Spectrum & finally RISC-OS). And whilst programming is now a little ahead of me, it’s still basically on/off, yes/no, if/then kinda switches. I can therefore understand the basics of php programming when I’m looking at it as I did after studying your feedback form, as such decided I wanted to add a little extra to the feedback thankyou form, I wanted to show the submitter the email address they entered & their IP. (I was also going to include the location, but decided such visible information may scare some people), though have to say, the way you did that bit of programming is VERY impressive!…
Anyway in the thankyou form, the “{EMAIL}” and “{FIRST_NAME}” were easy as they were already there, but when I entered “{IP}” nothing… Anyway, I discovered how to solve the problem, turns out (as you’ll know), you have to in a way, re-create the “{IP}” variable in the feedback.php form.
I’m sure many people will consider my comments as those of a simpleton, but I’m just beginning to understand the fact that php is server side, whilst html is world wide web side.
Thank you ever so much for providing this feedback form, it worked straight outta the box so to speak, it’s simply brilliant… I’ll be passing on what I’ve learnt from this experiance to my son who wants to be a programmer when he grows up, he’s already get me to buy him his own domain name & get him some hosting space!…
Thanks again,
John.
December 12th, 2008 at 10:34
Hi John,
Thanks for your comment.
You can add the
{IP}tag into your thank-you page.Then you’ll need to insert one line into the
feedback.phpscript:$tmpl = new Template();
$tmpl->set_file("template.form", $thankyou? "template.thankyou.html"
: "template.form.html");
$tmpl->set_var ("FIRST_NAME", $first_name);
$tmpl->set_var ("LAST_NAME", $last_name);
$tmpl->set_var ("EMAIL", $email);
$tmpl->set_var ("SITENAME", $site_name);
$tmpl->set_var ("SCRIPT_URL", getenv("SCRIPT_NAME"));
$tmpl->set_var ("IP", getenv("REMOTE_ADDR"));
$tmpl->set_var ("ERROR", $error);
$tmpl->pparse ("form", "template.form");
Hope this helps.
Michel
December 12th, 2008 at 16:26
Many thanks for the reply.
You see, you managed to explain that so simply compared to the trip around the world method I tried to explain it… Just brilliant!…
Kind Regards,
John.
January 3rd, 2009 at 01:31
Hi, Great Code, and thanks,
Two Questions Can i add to Attachment Fields?
and secondly for the love of money i cant remember how i Changed the permissions of the tmp folder ( 2 ) to 777. (CHMOD 0777 tmp), ive uploaded all required files, and changed everything,
but i run the feed back form the email is sent succesfully as i checked the email but at the top of the thank you page i get the following:
Warning: move_uploaded_file(tmp/dancaw.16.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/whiteli/public_html/feedback.php on line 78
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/tmp/phpWrrjbp’ to ‘tmp/dancaw.16.jpg’ in /home/whiteli/public_html/feedback.php on line 78
Warning: chmod() [function.chmod]: No such file or directory in /home/whiteli/public_html/feedback.php on line 79
Warning: file_get_contents(tmp/dancaw.16.jpg) [function.file-get-contents]: failed to open stream: No such file or directory in /home/whiteli/public_html/feedback.php on line 80
February 15th, 2009 at 23:02
Hi Michel,
Thanks for the code and hope you will bear with me on my questions below (new to php, very novice).
I have followed your instructions apart from “6) Change the permissions of the tmp folder ( 2 ) to 777. (CHMOD 0777 tmp)” how do you do it?
I tried running the script but I didnt get any email with the form details. The thank you form did not run as well after the submit stopped processing.
What am I doing wrong?
Thanks,
Grace
February 16th, 2009 at 05:36
Hi Grace,
If you upload files via FTP with a FTP-client program,
this program should allow you to change permissions of the files.
You either enter the command
chmod 777 tmpinthe program’ command line.
Or find such option in the program’ menu.
If you use a Control panel to upload your files, the panel
should have a feature to change permissions as well.
Concerning your problem.
At the first, send a test message without any attachment.
If you still not get an email, the problem is not in the
tmpfolder.As it’s used for attachments only.
Michel
March 11th, 2009 at 15:10
Michel,
Is it possible to add more fields to this script? I know my way around PHP for the most part and wanted to add 3 more fields, along with an option to upload 2 attachments instead of 1.
Is it possible to do that and how should I go about it?
Regards,
Shaggy
March 17th, 2009 at 12:57
Hey Michel,
this form has really helped me out since I couldn’t find a php form enabling attachments with such clear instructions..
Want to thank you a lot for sharing..
A quick question if you have time to answer..
Is there a way to enable attaching more than one file? I know how to do it in the html + adding a input name to it
but clueless on what to do in the php file to attach it :S
appreciate any help.
Thanks a bunch in anyway for the form
Majid
March 17th, 2009 at 13:43
Hi guys,
It seems the multiply attachments become popular.
So. In order to answer on all questions by one hit,
I will create a new version of this script at this week.
The new version would allow to have a multiply attachments form.
Michel
March 17th, 2009 at 14:41
Wow that sounds great!!
Seriously, can’t thank you enough. I’ve just done customizing the code to my page. Even changed the last name filed to a numberical field for phone numbers. Only problem I stumbled upon was getting the sender’s name to be written in Arabic. It keeps sending me blanks, english works fine.
Tried changing the charset on the html, didn’t work..
If nothing across your mind don’t bother me, I’ll keep googling it up.. Appreciate your help Michel.
March 23rd, 2009 at 10:46
Hi guys,
The new “multi-files attachment” feedback form is available with the same link feedback-form.zip
Now you can use any number of attached files.
The default form-page template allows to add a new file-field dynamically.
Also you can insert additional text fields into your form and use the names of these fields (as uppercase tags) in the message without adjusting the script.
For example, you can add a field like this:
Your Phone:
<input name="phone" type="text">Then use the phone name in uppercase inside your message:
Phone number: [PHONE]Please note, the template and config files were renamed as
feedback.config.phpfeedback.form.html
feedback.thankyou.html
The GeoIP function is disabled by default.
Michel
March 29th, 2009 at 15:07
hi Michael… I downloaded your awesome script today and it works perfectly if i dont put any attachments but it doesnt seem to send the email when i put the attachment eventhough the chmod of my tmp file is 777. i tried to send an email with a jpg attached several times and just to make sure i checked the tmp file
but it is empty.
March 29th, 2009 at 18:40
Hi turmex,
The latest version of Feedback form doesn’t use the
tmpfolder at all.It opens files from the server’s temp-folder directly.
Please make sure the PHP on your server allows to upload files and open files from the
/tmpfolder.Michel
April 27th, 2009 at 02:19
Michel,
Thank you for sharing your scripts. I have been searching high and low for this solution and it would be really sweet if I can get it running. I have this problem running this script - it keep prompting this error message: Please enter your Real Email address - and yes, I’ve entered a real email address. Any idea?
April 27th, 2009 at 04:02
Hi Kwlee,
How your email address looks like?
The script checks the email format,
so you can’t just type something similar test@test
Michel
April 27th, 2009 at 04:14
Michel,
I’ve tried with various email addresses: kwlee@tcsb.com.my, lkw_comex@hotmail.com etc. But always return the same error message. What have I done wrong? Appreciate your work here.
May 12th, 2009 at 10:31
Michel,
I need a form for a UTF-8 encoded page in Russian.
The installed form works, but does not return user’s name entered in Russian.
I there a way around?
Thanks
May 18th, 2009 at 17:03
Hi Efacade,
Please download a new version (with the same link).
It supports Charset in email messages.
You need to enter the correct charset inside the
feedback.config.php:$charset = "windows-1251";Or
$charset = "utf-8";This should be the same as you have in the “Content-Type” META tag of your pages:
<meta http-equiv="Content-Type"content="text/html; charset=utf-8">
Michel