DIGIT-ARC read-only archive · snapshot: July 23, 2026

[Readymade script] A feedback/contact form for your website

22 posts · originally from https://geek.digit.in/community/threads/readymade-script-a-feedback-contact-form-for-your-website.73786/

victor_rambo
victor_rambo Original post #1
Nov 21, 2007 at 9:57 PM
You can use this form to allow your visitor contact you for enquiries or feedback. you don't have to give out your email address so that people wont spam you.

Step 1: The script. It has two parts:
1. The feedback form which is to be filled by the visitor. It is in plain HTML. It will contain necessary variables such as 'From', 'subject', 'message'.
2. The PHP script which would be hosted on your server. This script will process the variables in the feedback form and send the email.

The HTML form:
Copy below code and save it in a file named as feedback.html. When a visitor clicks on fedback link, he should be taken to feedback.html
Code:
<form method="POST" action="/feedback.php">
<table border="0" cellpadding="0" width="63%" cellspacing="0">
  <tr>
    <td width="23%">Your email address:</td>
    <td width="77%"> <input type="text" name="from" size="40"></td>
  </tr>
  <tr>
    <td width="23%">Subject of mail: </td>
    <td width="77%"> <input type="text" name="subject" size="40"></td>
  </tr>
  <tr>
    <td width="23%" valign="top">Your message:</td>
    <td width="77%"> <textarea name="body" rows="7" col="20" cols="34"></textarea></td>
  </tr>
  <tr>
    <td width="23%"> </td>
    <td width="77%">
<input type="submit" value="Send feedback">
    </td>
  </tr>
</table>
</form>

The PHP script:
Copy below code and save in a file named feedback.php
Code:
<?php
$to="youruserid@yourdomain.com";
$subject= $_POST['subject'];
$body = $_POST['body'];
$headers= $_POST['from'];

if(mail($to,$subject,$body,"From: $headers"))
{
echo "Thank you for your valuable feedback";
}
else
{
echo "Oops, there seems some problem with sending the feedback. Please try again later. If problem persists, you may send your feedback directly to $to.";
}
?>

You MUSt replace youruserid@yourdomain.com with your email address.

Step 2: Now upload both the files to your server. You will have to change the relative path of the feedback form if you are not uploading the two giles to the same directory.

Step3: Format the elements as per your needs.

Personal notes:
  • If your host does not support PHP, you can signup for free PHP hosting at *www.x10hosting.com or similar site. If you will do so, you MUST change the action attribute of the HTML form to absolute URL such as *www.username.x10hosting.com/feedback.php
References:
  • Adopted the PHP mail function from *www.freewebmasterhelp.com/tutorials/php/5. Please note that there seems some problem with sequence of variables used there. I have used the correct sequence after trial and error.
chesss
chesss #2
Nov 21, 2007 at 11:27 PM
If we submit the form through the same window, the user will get a blank form when he clicks 'Back' button to make some correction.
not if the user is using Opera (and firefox?)
krates
krates #3
Nov 21, 2007 at 11:46 PM
you made the script after 2 hours before i have done here

*www.thinkdigit.com/forum/showthread.php?p=666452#post666452

and this must go to programming
victor_rambo
Nov 21, 2007 at 11:55 PM
kushagra_krates@yahoo.com said:
you made the script after 2 hours before i have done here

*www.thinkdigit.com/forum/showthread.php?p=666452#post666452

and this must go to programming
Changes made to the script: The target=_blank attribute has been removed considering that pop-up blockers may block the message from being sent. Some pop-up blockers do block target="_blank" hrefs.

@ Kushagra, This thread is not meant to display coding, its meant for people who want to make a contact form for their site. So this should be in tutorials rather than programming.
V
vaibhavtek #5
Nov 22, 2007 at 11:38 AM
nice 1
V
vaibhavtek #7
Nov 22, 2007 at 11:58 AM
i doesnot thinks it is wrong section.
he had made a tut. and posted in tut. section....
victor_rambo
Nov 22, 2007 at 6:10 PM
Thanks!

yeah! its a utility. Not a programming one!

and I wonder what sort of visibility would this have in programming section which has only 2 or 3 viewing.
V
vaibhavtek #9
Nov 22, 2007 at 6:12 PM
thats correct buddy
QwertyManiac
Nov 22, 2007 at 9:09 PM
rohan_shenoy said:
and I wonder what sort of visibility would this have in programming section which has only 2 or 3 viewing.
It isn't about more reads you get, its about people finding things easily when needed.
victor_rambo
Nov 22, 2007 at 9:15 PM
QwertyManiac said:
It isn't about more reads you get, its about people finding things easily when needed.
Its not about how many read this tutorial, it about how many can see it when they need it.

The description given for the Programming section is hi-funda enough to put off a newbie.
QwertyManiac
Nov 22, 2007 at 9:19 PM
*shrugs* I'd head to an apt section if what I'm looking for is PHP. Your call anyway.
victor_rambo
Nov 22, 2007 at 9:30 PM
QwertyManiac said:
*shrugs* I'd head to an apt section if what I'm looking for is PHP. Your call anyway.
Not everybody knows if that is made in PHP.
Moreover, it is may be possible to make such script even in CGI, ASP, Perl,etc.
So how many sections should a member search in?
harryneopotter
Nov 27, 2007 at 2:27 PM
thnx buddy ...... but plz tell me one more thing ....... wat if i want to redirect to a webpage after successfull submission ......wat change shld i do in ur script ?? plz help soon ....
Gigacore
Gigacore #15
Nov 27, 2007 at 4:05 PM
thanks :)
krates
krates #16
Nov 29, 2007 at 6:13 PM
harryneopotter said:
thnx buddy ...... but plz tell me one more thing ....... wat if i want to redirect to a webpage after successfull submission ......wat change shld i do in ur script ?? plz help soon ....

use redirect(url name);

harryneopotter
Nov 29, 2007 at 8:50 PM
thnx ............. can i make costum scripts for any form easlily ? mean if i have more fields in the form then how wld i link them to script ? plz tell if u can ...........
Gigacore
Gigacore #18
Dec 10, 2007 at 9:07 PM
thanks a lot rohan_shenoy, i've added it to my site!
victor_rambo
Dec 10, 2007 at 10:29 PM
harryneopotter said:
thnx ............. can i make costum scripts for any form easlily ? mean if i have more fields in the form then how wld i link them to script ? plz tell if u can ...........
Define the variable in PHP script and then have input fields for them in HTML form.
J
Mar 29, 2009 at 2:43 PM
If i want to recive this form data to my yahoo or other mail
Disc_Junkie
Mar 29, 2009 at 3:17 PM
^ Look at the date before posting.
S
shinzuka #22
Dec 4, 2012 at 3:35 PM
This is awesome! looking at the date it was created and when I found this, it still made wonders. Thanks!!! :razz: