7
Feb
2008
LightForm ::: Free Ajax/PHP Contact Form
By Jeeremie. Posted in AJAX / Javascript, Articles, PHPLightForm is a free Ajax/PHP contact form. It combines FormCheck2 for fields validation and NiceForms to style text fields and textareas.
Demo:
Download:
Use of this contact form is free of charge but the copyright notes in the footer must remain intact.
I would appreciate if you send me the URI of your site if you use LightForm.
Updates:
May 28, 2008: Textarea bug fixed.
Features:
- Form Validation using FormCheck2.
- Spam Check.
- Display user IP, user agent and referrer in the message.
- Display a dialog box when message sent succesfully.
- Inputs and textareas are styled with NiceForms.
- Works in the most recent browsers (IE6+, Firefox, Opera, Safari and Netscape).
Installation:
- Download and unzip the file
- Copy all the files to your root Directory
Usage:
Open index.php in your web editor (e.g. Notepad) and change the email address line 55:
$to = 'yourname@domain.com';
License:
The CSS, XHTML, PHP and design is released under Creative Commons Attribution v2.5.
FormCheck2 is released under the MIT license.
NiceForms is released under no specific license. You are free to use and modify but you must provide credits to the author.
Caution
Form validation won’t work anymore if users disable Javascript.
Popularity: 44% [?]

February 7th, 2008 at 11:01 pm
[...] A new default theme is avalaible (thanks to Jeremie!) [...]
March 7th, 2008 at 1:32 pm
Great. It works smoothly.Firebug detects a slight error on the congrats page though:obj has no properties while (obj.offsetParent) {on line190 of niceforms.jsKeep up the good work.
March 18th, 2008 at 3:56 pm
It looks beautiful!Good work!I’ve translated it a little to Simple Chinese.You can visit it here.
March 25th, 2008 at 4:02 am
Hi there, i got a question about this form…How I can change the question and of course the answer of the part “are you human?” I really don’t know much of javascript.I appreciate any help, thanks.
March 25th, 2008 at 10:50 am
Artico,
open index.php in a web editor and go to line 152 and change the text:
<label for="spamcheck"><span class="blue">*</span> <acronym title="[ Spam prevention ]“><strong>Are you human?</acronym> : <span class=”blue”>2 + 3 = ???</span></strong></label>To change the answer, open /js/formcheck/formcheck.js and go to line 155:
spamcheck : /^[5]+$/,… and change number 5 for another number.
You must also change the question line 136 to match your answer:
spamcheck : "2 + 3 = ???“Let me know if you could do it.
March 26th, 2008 at 2:57 am
Hi Jeeremie, that was easy to change, thanks for your help.
April 22nd, 2008 at 8:37 am
I wanted to know how could I add some radio and checkboxs to my form, because they don’t appear…Thank a lot!
April 22nd, 2008 at 10:44 am
It is normal Paco, I didn’t create radio and checkboxes images for this form. If you really need some for your form, go to Badboy.ro and download his form to get the images.
I hope it helps.
April 22nd, 2008 at 10:49 pm
Merci pour le lien!!Oh j’avais pas vu que tu étais francais, j’ai parlé anglais pour rien :)Bonne continuation, et pour le blog, il va droit dans mes RSS ^^…
April 24th, 2008 at 9:12 pm
IS it easy to add more fields?
April 25th, 2008 at 10:10 am
Very nice! how can i put this form into my About page in Wordpress?Thanks!
April 25th, 2008 at 10:40 am
Hi again, i translate the “LightForm\js\formcheck\lang” formcheckLanguage = { required : “Campo requerido.”, alpha : “Este campo acepta solo caracteres alfabéticos.”, alphanum : “Este campo acepta solo caracteres alfanuméricos.”, nodigit : “No se aceptan dígitos.”, digit : “por favor ingrese un número válido.”, digitmin : “El número debe ser de al menos %0″, digitltd : “El valor debe estar entre %0 y %1″, number : “Por favor ingrese un número válido.”, email : “Por favor ingrese un email válido:”, email : “Ingrese un email válido: <br /><span>Ej. sunombre@dominio.com</span>”, spamcheck : “<span>2 + 3 = ???</span>”, phone : “Ingrese un teléfono válido.”, url : “Ingrese una URL válida: <br /><span>E.g. http://www.dominio.com</span>”, confirm : “Este campo es diferente de %0″, differs : “Este campo tiene que ser diferente de %0″, length_str : “Texto muy corto, tiene que ser entre %0 y %1″, lengthmax : “Texto muy corto, debe tener un máximo de %0″, lengthmin : “Texto muy corto, debe tener por lo menos %0″, checkbox : “Por favor marque el chekbox”, radios : “Por favor seleccione un radio”, select : “Por favor seleccione un valor”}If you want i can translate all files, please help me with Wordpress!Thanks again
May 1st, 2008 at 7:02 am
I quite like this contact form you have made.If you are using this on your website then I reccomend you download the YUI Compressed mootools as it is only 65kb compared to the supplied 180kb.I am currently trying to turn this into a simple wordpress plugin. It wont have any of the fancy functionality and admin interface of cforms though but you should still be able to get it to work with minimal php/html coding
May 1st, 2008 at 11:04 am
Thanks for the info. I didn’t know about this YUI compressed tool. That’s good to know.
It would be great you create a wordpress plugin. Let us know about it.
May 8th, 2008 at 10:15 pm
Copyright in footer? How can you copyright this? You don’t have rights to standard scripting methods of JavaScript and PHP. Hey, it’s a nice form - don’t get me wrong - but think about how much you’ve been given by the community in terms of free info/advice on forums, and great languages like PHP and JS. To be part of the community, you have to give back. If you are going to “protect” your work, consider a Creative Commons license - which is a lot different than a copyright (which implies that you own all the intellectual property associated with your work - which you don’t).Better yet, just request that people give you credit - you’ll find most will - especially if they can post your Googlicious inbound link to a “credits” page somewhere on their site.Else bundle it up with LTS and charge for it.
May 8th, 2008 at 10:48 pm
Lawrence,
Did you have a bad day? Where have you seen I put copyright by web-kreation? I say in the footer:
“© Some Copyrights by their respective authors (if you are not sure visit authors’ websites).”
This means copyrights by Moo Floor and BadBoy.ro for the PHP and JS.
I have never pretended I knew any PHP or JS, neither I have intented to create something original. I just wanted to create a nice form using some existing scripts that I liked very much. And since I liked the result, I wanted to share it with others. Is there something wrong with that?
Moreover, I say on my blog:
“The CSS, XHTML, PHP and design is released under Creative Commons Attribution v2.5.”
So next time, before you insult someone, read!!!!
I am now waiting for your apologies.
May 8th, 2008 at 11:39 pm
Hmmm…. no, not having a bad day. Just thought you didn’t know about that stuff. Turns out you do. Which is great. I first read about the copyright requirement on Smashing Apps here and then saw the same phrase repeated in the Download section above: “Use of this contact form is free of charge but the copyright notes in the footer must remain intact.”So, yeah, I, uh, apologize for not reading further and seeing the license information below. And for everyone’s benefit, the license info is in fact repeated in the actual php script download (not that I looked before).So, now that I apologized, I hope you’ll forgive me. Now, that I see the license info, all I can say is that it is, at best, a bit confusing - or perhaps conflicting information. Even if I had read down to the License section, I’m not sure I would have known which information supersedes which. But, I probably would have left a different comment entirely, admittedly. One asking a question, rather than assuming. You got me - two points for you. Your ball.
May 9th, 2008 at 11:35 am
Yes, don’t worry. I accept your apologies. That’s not a big deal.
Cheers!
May 14th, 2008 at 1:35 am
its possible add new list menu or drop down menu in your script?whow? i try insert this list menu but i dont see nothing when i try in server!! can you explain me whow to work?thanks
May 14th, 2008 at 4:27 pm
ack Said:
“Great. It works smoothly.Firebug detects a slight error on
the congrats page though:obj has no properties while (obj.offsetParent)
{on line190 of niceforms.jsKeep up the good work.”I have the same experience. Other than that it all works fine. Thank you for sharing this piece of work.
May 17th, 2008 at 10:39 am
[...] LightForm is now a Wordpress plugin (only works with latest Wordpress v2.5.1). The plugin is called WP-Lightform and can be downloaded here. Thanks to Alex Rogers for the good work. [...]
May 21st, 2008 at 1:47 pm
CARAAAAAA!!! vc me ajudou muito valeu mesmo. Espero manter contato
May 24th, 2008 at 2:38 am
Hey! Love your stuff!
I have a problem… I did everything right and it just won’t send email… it just gives me error…your massage faild to send!
I can see css, nice form, form check works… it just wont send…
thx!
May 24th, 2008 at 11:39 am
@ mmartinovich: The script works fine. I have tried it few times and i could always send mail. Could it be a problem with your server or email address?
May 24th, 2008 at 4:44 pm
Everything is fine on server when I use another script… it sends I get it…
Seems something is going on with send mail command…I can’t figure it out… everything works smooth except it won’t send…
Once when I used another script it said ” You are coming from unauthorized domain… could it be something with this thing?
Can you write down a send mail part of script ’cause I’m not so good with PHP…please! I love this thing! You did awsome job!
I just HAVE to make it work!
thx!
May 25th, 2008 at 6:29 pm
Ok… i figuered out why it wouldnt want to send email…
had to add this line before mail function:
ini_set(”sendmail_from”, “postmaster@domain.com”);
Now it works like a charm!
THX, bro!
May 27th, 2008 at 11:16 am
I am using your plugin in a wordpress page and I would like to have two different forms: a contact form and another one.
I tryed to do that by having two plugins with different names but the same one and change the form in one of them. But the problem is that both appear with the code [lightform].
Is there a way of having different forms that will show with different code in the posts?
Thanks.
May 27th, 2008 at 11:35 am
Jose,
Do you have a url?
May 28th, 2008 at 1:15 pm
This is my URL.
Thanks.
May 29th, 2008 at 4:59 pm
nice job man!
very useful
it was not 100% clear to me how text and translations are managed but now i think i’ve got them
May 29th, 2008 at 7:19 pm
Hi,
First, THANK YOU for this awesome contact form.
Second, is there a way to limit a user’s URL input in the message box to at least 3? Spammers usually sends dozens of them. So I think this would be another good way to avoid spam.
Thanks again and more power!
_a
May 29th, 2008 at 10:22 pm
If it’s not possible, is there a way to ban some specific words like ‘viagra’ in the message box?
I actually tried doing it (please don’t laugh I’m no expert) but only works with one character (like ‘v’ ‘i’ ‘a’ ‘g’ ‘r’ ‘a’) :
noviagra : /^[^"viagra"]+$/i,
How to make it so it’s the whole word (”viagra” itself)?
–
Thanks!
May 30th, 2008 at 6:50 am
I’m using the wp plugin with your form. it’s working very good!
just to send you the link to my web, as you asked for it.
thanks again
May 30th, 2008 at 9:58 am
Thank you Mache. However, it is Alex rogers you should thank for porting LightForm to Wordpress.
June 4th, 2008 at 6:21 am
Can someone tell me how I can redirect to a different page instead of going back to the source page?
June 4th, 2008 at 4:28 pm
I’m getting this error:
Firefox can’t find the file at /Users/laurenyoung/Sites/parsec/LightForm/.
don’t know why…
form looks great, I’d like to use it, if i can get this error thing figured out!
June 4th, 2008 at 5:32 pm
@ Alex: Open index.php and go to line 189. Change the message for this:
<div class=\"MsgSent\"><h1>Congratulations!!</h1>
<p>Thank you <b><?=$name;?></b>, your message is sent!<br /> I will get back to you as soon as possible.</p>
<script type=\”text/JavaScript\”>
<!–
setTimeout(\”location.href = \\’http://www.yoursite.com\\’;\”,5000);
–>
</script>
<p>Please, be patient. You will be redirected to the home page in 5 secondes.</p>
</div>
Don’t forget to change “yoursite.com” for your site. The script will redirect the visitor to the new page after 5 secondes.
June 4th, 2008 at 5:48 pm
@ Allen: You should better ask Luca, the author of Formcheck2. But, he is a very busy man. I don’t know if he will have time to answer you.
@ Justin: no idea. Do you work on your localhost? If so, do you use a software such as EasyPHP?…You should tell us a bit more about your problem if you want someone to be able to help you.
June 4th, 2008 at 6:41 pm
I’m working off my localhost. The error says can’t find file at :
.
I just uploaded the files to my server and tried to use it, and this is the error I’m getting.
Thanks for any advice.
June 4th, 2008 at 6:50 pm
Could you send us the URL? We don’t see your error message.
June 9th, 2008 at 2:23 pm
Hi, thanks my friend for the script I’ll use it in my other site
http://www.clickclick.ws
i’ll release soon the new design of it..
have a good day
June 9th, 2008 at 3:40 pm
I tried it,, but it give me an error message for failed sending
check it here
http://clickclick.ws/LightForm/index.php
please reply to my email
June 9th, 2008 at 3:50 pm
This looks like you don’t have a SMTP server installed on your server? You will have to check this with your web hosting company.
In any case I don’t think it is a problem related to my contact form unless you have screwed up the code.
June 10th, 2008 at 11:37 am
I didn’t use any of the code!
just installed it in the site and it is not working!
June 10th, 2008 at 11:49 am
So did you check if you have an SMTP server?
June 10th, 2008 at 8:38 pm
I don’t think that it is from the SMTP!!
because i’m using a script (contact form), that’s work just fine without any problem
this is it
http://www.q8ieng.net/mailform/mailform.php
I’ll contact my support and i’ll let you know
June 10th, 2008 at 8:47 pm
Then, I really don’t know. Many people have downloaded this script and no one reported a similar problem. Besides, I have tested this script many times and it works just fine.
June 10th, 2008 at 9:57 pm
they told me
Yes, of course. We have SMTP server (EXIM) running on all our hosting servers!!
so, where did u think the problem is?
June 18th, 2008 at 4:40 pm
I am getting the following errors:
Notice: Undefined index: name in D:\Sites\www.mydomain.com\form\index.php on line 12
Notice: Undefined index: email in D:\Sites\www.mydomain.com\form\index.php on line 13
Notice: Undefined index: website in D:\Sites\\www.mydomain.com\form\index.php on line 14
Notice: Undefined index: subject in D:\Sites\\www.mydomain.com\form\index.php on line 18
Notice: Undefined index: message in D:\Sites\\www.mydomain.com\form\index.php on line 27
Can anyone help me? I didn’t touch anything from the code, just change the email address
June 19th, 2008 at 4:37 pm
Thanks Jeeremine, I’ll try it
June 25th, 2008 at 4:38 pm
Actually, I did everything, and everything is going alright
except for the LightForm, I didn’t got how to place that script in it :\
July 12th, 2008 at 3:55 pm
Great ! But there is a problem with IE explorer 7, when i fill a box, the background image is leaving… just test… if you have a css solution for this, thanks a lot !
Best regards !
July 12th, 2008 at 4:10 pm
Hello Meandme,
It works fine for me in IE7. Has someone noticed the same bug in IE7?
July 12th, 2008 at 4:15 pm
Hi Jeeremie
i said before: it works really great but if you disable Javascript, you can do what you want - also sending nothing - it comes the “congratulations Site.
I have a idea:
in your example fom lightscript use the tag
and give a hint that they must activate Javascript
Else it dont run/work
If you have a better idea - go ahead
Greets

July 13th, 2008 at 1:50 pm
Thx very much for this work
July 14th, 2008 at 10:47 pm
Hi Jeeremie
Here i am again - sorry for double-Posting - sorry for my bad english!
“in your example fom lightscript use the tag
and give a hint that they must activate Javascript
Else it dont run/work”
in your example from lightscript use the “NOSCRIPT” TAG.
And: THX for that nice work !!
July 15th, 2008 at 8:19 am
Hello dosntMatter,
Actually your comment was posted but when I redesigned this site, I had to move things around and unfortunately, I lost the latest comments and yours as well. Sorry for that.
I will think about this feature for LightForm but not right now. As you can see, this site is not quite finished yet.
Thanks anyway for your comment.
July 18th, 2008 at 7:02 am
Hi, i get this IE7 Browser error message in german after sending the form:
Line: 191
Sign: 2
Error: Object necessarily
After i delete the complete Line 191 in the index.php the error-message was the same. Is there a javascript error?
Thanks a lot!
July 20th, 2008 at 3:00 pm
Hey Jeeremie,
Just wanted to say that I’ve searched the web for a very slick looking Contact Us Form that used some PHP, AJAX and JavaScript and your form by leeps and bounds is better than anything I’ve come across. It is freakn’ AWESOME!!! I haven’t installed it yet =) But saw the Demo and looked over the code. So intense!!
Also thanks for being so detailed and actually taking the time to add comments in. Makes things so MUCH easier on newbies.
THANKS!!!!!!
jason
August 6th, 2008 at 12:17 pm
Hey Jeeremie,
your forms works with textinput and textarea but not with select,
The alert box doesn’t appear when i add a
Please choose
Under 10
Between 10 and 21
Over 21
i mean the script doesn’t validate it(select)
can you help me,
thanks very much for your work.
August 6th, 2008 at 12:24 pm
I’m sorry, i forget to add
for the XHTML codeHey Jeeremie,
your forms works with textinput and textarea but not with select,
The alert box doesn’t appear when i add a
Please choose
Under 10
Between 10 and 21
Over 21
i mean the script doesn’t validate it(s