Here is a nice contact form for your website.
This contact form will return a validation message if the message was sent succesfully.
It will also display an error message if you try to send an empty message or if the e-mail is invalid.
The Demo
There are only two scripts for this simple contact form:
- contact.php : the PHP contact form itself (contact.php)
- style.css : the CSS page (style.css) to control the layout of the page
Download:
Download (7.0 KiB, 15,552 hits)Popularity: 19% [?]


June 30th, 2007 at 2:14 pm
I tested you script.
http://www.holistica.com.br/artigo1/contato/contact.php
But my internet provider don´t send the messagen for my inbox. Look, message the CONGRATULATION, but don´t.
Very Good.
July 1st, 2007 at 8:37 am
great site for helping people!!…wtg
July 2nd, 2007 at 2:05 pm
Hello Adao Braga,
I tested the contact form you installed on your server but I can’t see what is the problem. Did you changed the email address to be your own in the contact.php page (user@email.com – line 61)? If it is not working, try changing the email to be something else or contact your internet provider. And by the way, check your spam box. It is possible your email provider moved the mail into it.
I hope it helps you.
July 10th, 2007 at 10:20 am
is this good for a flash form ?
my form in flash gives me a message of message sent but i get no emails
July 10th, 2007 at 11:05 am
Hello Tamara,
I have no idea. I never tried to adapt it to a flash form but I suppose it is possible.
However, your problem may due to your e-mail provider. Try to contact them and see if they can first fix it. If not, then it could be a problem with your flash form.
Let me know.
January 28th, 2008 at 12:49 pm
Hey, PHP guy!
I am getting this problem,
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP 2.0b1\www\Shop On!\categories.php on line 68
I know there is some problem with the mySQL. But EasyPHP is showing it to me as started.
I have the database in the MYsQL data folder as well. Do you have any idea, what might be the problem ?
P.S. plz reply on my email adress! Thanks
July 31st, 2008 at 10:46 am
great site for helping people
August 1st, 2008 at 5:04 am
Hey, Any plans for expanding the form to include SMTP authenitcation?
Ollie
August 1st, 2008 at 3:59 pm
No, not at the moment but that’s a good idea Ollie. I will think about it. Thanks!
August 2nd, 2008 at 10:16 am
Hey Jeeremie,
I know this form is free and so any advice would be greatly appreciated, but understand if you don’t have time to look at it.
I love this form and am using it a lot but I’ve come across a need for some drop down select menus. Which it works fine and collects the data and emails it, the problem comes in if there is any type of error, the drop-down select menus RESET because there is no way to tell them what the original value was that had been selected by the user.
I’ve tried several things without success. Thought you might have some advice to make this work. (I sent you an email with the code if you want to look at it).
Thanks, the site looks AWESOME!!! BTW, FYI, MooFlow works in Firefox 3+ guess I was behind the times =)
j
August 2nd, 2008 at 11:48 am
Thanks Jason,
I got your email two days ago but I didn’t have time to look at it yet. I will as soon as possible.
August 5th, 2008 at 1:40 pm
Hey man, no problem, I just appreciate it! Hope things are going great.
August 5th, 2008 at 6:12 pm
Jason,
Your code was correct. Just replace:
…by:
And it should work! you can download the (simplified) code here if you want.
August 5th, 2008 at 6:23 pm
By the way, I will release in a couple of weeks the quote form I used on my old site. It was based on this contact form. Since I am not using it anymore, I think it is a good idea to give it away. I will publish it in approximately one month as I have other posts in the queue waiting to be published.
August 8th, 2008 at 8:50 am
Hey Jeeremie,
Thanks for looking at it. I got it to require it so that if it’s not selected it gives an error, but the problem remains that if any error happens, then the select box doesn’t remember what was selected and reset itself back to the default… does that make sense?
Sorry if I was not more clear. I really appreciate your time.
August 8th, 2008 at 3:37 pm
I tried this and it works! Check it by yourself (click on [+] to expand the code) :
August 8th, 2008 at 4:08 pm
By the way, if you want to validate a phone number in your PHP contact form, add this code:
… like this: (click on [+] to expand the code)
The code “/^[0-9]{6,}$/” will check if the phone number contains only numbers ([0-9]) and if the number contains at least 6 characters ({6,}). You can increase this number if you want. For example, in Spain, phone numbers contains at least 9 numbers. Your code could be: “/^[0-9]{9,}$/”.
August 8th, 2008 at 4:24 pm
DUDE, did you re-write the entire form?? OH MY GOODNESS!!! I’m so so sorry. I just thought it might be a quick fix. I did not mean for you to have to do all that work.
Nevertheless it works AWESOME!!!! Perfect. You should upload it as a download as a NEW form with your other two because it’s completely different in a lot of ways =)
THANKS!!!!!!!!!!
August 8th, 2008 at 4:38 pm
You are welcome Jason. I enjoyed it anyway!
August 20th, 2008 at 1:34 pm
hi,
the problem statement for comment number 6 of anwar is:
please check your connection variable and the database variables in the mysql_connect and mysql_select_db.
October 4th, 2008 at 10:20 pm
Hi Jeeremie,
what a piece of simple php script, its a best one i came across.
Can you please tell me how can i add drop down box to your wonderful script which should include in mail
dropdown1 : Date
dropdown2 : month
dropdown3 : year
please help me its important to me.
November 4th, 2008 at 8:05 am
I just get this errormessage:
The POST method has been disabled by the server administrator
November 4th, 2008 at 9:59 am
Maybe your host does not allow to send messages with the post method. Contact your host and ask them.
December 12th, 2008 at 2:04 pm
Hello,
Let me thank you for this nice contact form.
For those who needs drop downs, I added Jeeremie’s code to the original. you can download it here until Jeeremie updates his version.
December 12th, 2008 at 2:14 pm
Thanks Mohamed. Great work!
Anyone, if you need a more complex form, you can download my free quote form on my freebies page. It has some drop down menus, radio buttons and so on.
December 15th, 2008 at 1:43 pm
I have added a captcha protection to the contact form instead of the 2+3 problem. download from here.
February 8th, 2009 at 5:19 am
post #16 is good the error checking is in order and the select box works great (i have not been able to do that before i found this script) i have customized the error messages, well as opposed to messages the text / textbox border goes red and i have removed the else if’s for the error check and replace with standard if so it does all the checking at once useing an array and got that fine, however i would appreciate help with a very lightweight captcha script (4 or 5 letters / numbers long NOT case sensitive and ability to change the bg / text colour but must be a very small image size (kb’s) could you help ?
March 6th, 2009 at 6:50 am
Do not use this script. It is vulnerable to e-mail header injection (allows an attacker to send spam from your hosting account) and XSS (allows a 3rd party site to steal your users’ cookies). This is one of the few “free” contact forms that isn’t full of holes.
March 6th, 2009 at 6:59 am
I apologize if I was a little harsh, but PHP security is very important, especially if your encouraging others to use the code. I highly recommend this book. I should also mention your Wordpress templates are beautiful.
March 6th, 2009 at 10:33 am
No problem. Thanks for letting us know. I actually didn’t know.
March 25th, 2009 at 10:57 pm
[...] 20. PHP Contact Form Script [...]
March 31st, 2009 at 5:01 am
[...] 20. PHP Contact Form Script [...]
April 8th, 2009 at 5:38 pm
[...] 20. Контактная форма на PHP [...]
April 13th, 2009 at 6:49 am
super work fine
June 1st, 2009 at 1:08 am
Hi Jeeremie,
So is this still a safe form to use? I’m trying to get this into a website but I can’t seem to get it to work after I press send. Maybe it’s because that I’m using it with spry and it jumps/ slide back to “home” from “contact”. So I have to click on “contact” again and it display the msg, “congratulation… “. It does not stay at “contact” after send. It’ll be greatly appreciated. Thanks for your time.
August 9th, 2009 at 1:12 am
[...] 20. PHP Contact Form Script [...]
September 19th, 2009 at 3:11 am
Hi
I was testing the form and I noticed the first error message is “ Please enter a subject!”
Is there any reason the Subject error message showing up first and not Name? and how would I change the order?
September 30th, 2009 at 5:04 am
Saludos des de Lima Peru gracias por el Php de contactos lo voya meter en mi web
March 7th, 2010 at 9:31 am
[...] 20. PHP Contact Form Script [...]
March 11th, 2010 at 11:57 am
Hello,
I want to use this form but just the email!!!
I mean something like,
Please, enter your email : xxxxx
2 + 3 = xxxxx
That’s it, I tried but It didn’t work, I am not an expert in php coding,
Thanks in advance man,
Beho