How can I get a form to work in HTML?
Asked by
Link (
327)
May 7th, 2009
Okay I can make a form in HTML, but how the heck do I make it work (e.g. send a user’s comment to my inbox, pop up a thank you page, send users an email)?
I realize this is probably a complicated questions and you don’t have to go into detail for each and every way, just give me one way. Thanks dudes.
-Link
Observing members:
0
Composing members:
0
9 Answers
It’s not done in HTML, it’s done in a server-side script such as PHP or Ruby or Python, etc. Most servers have at least one of the above languages installed, so you can probably look for a PHP or PERL script to do that for you.
Hotscripts.com is a good place to look. Just start with PHP or PERL or whatever your server supports, then find the contact or mail scripts, etc.
You can also go with a service like Wufoo.com to handle everything for you.
You’ll probably need to write some Javascript in addition to HTML. However, StellarAirman has it – all the interesting stuff happens on the server end. PHP and Perl are widely used. ASP classic has been mostly forgotten about, but it’s still supported on a lot of servers. And you have the advantage of being able to run it out of the localhost server on the same computer you’re using to build the site, without having to set up anything but IIS. That can make testing and debugging less painful, but not easy. It’s a pain in the ass no matter what you do.
Okay thanks a lot so far guys. And yes it’s a pain! But okay I get what you’re saying. I’ll have to add a Javascript statement to the form to get it to communicate with the server right? Okay so what happens on the server end? Is there a document waiting there? Let me try to explain what I mean:
To write a form all you gotta do is type something like this in an HTML editor:
<form>
<p>Name:</p>
<input type=“text”>
<input type=“submit”>
</form>
What would I have to do on the server end? Like is PHP code that I can write the way I can write HTML or is it something completely different? What do I have to do to make the connection from the HTML code to the server?
-Link
By the way I have Notebook ++ and I noticed that one of the language options is PHP. Am I supposed to write up the server end script and save it in PHP? and then plug it into my server somehow?
Rather than duplicate what is already out there in dozens of tutorials, I’d recommend some of the links on this page to give you a basic idea of how it works: http://www.google.com/search?hl=en&safe=off&rlz=1C1GGLS_enUS308IQ309&q=php+contact+form+tutorial&btnG=Search
Basically the form tag will point to the PHP page which will take the data and do something with it, whether than be putting it in a database, or emailing it. Substitute whatever language you want to use for PHP in that google search. Make sure your server supports the language you choose.
Javascript isn’t needed to send a form, it’s usually used for data validation, formatting, etc. Unless you want to do some AJAX business (like here on Fluther when you submit an answer and it doesn’t reload the whole page).
PHP is just written in a text editor like HTML, you don’t have to compile it or anything. It’s a scripting language, not a compiled programming language. Most web languages like PERL and Python and ASP are the same way.
Whatever you end up doing, the learning curve even for something as simple as “hello world” is pretty steep. This is a fairly good book to learn Perl from:
http://www.amazon.com/Beginning-Perl-Second-James-Lee/dp/159059391X/ref=pd_sim_b_15
but check out the web resources first. Anything you can find with complete examples, pages and scripts that you can download, use, and freely modify, will be a great help. Nobody writes this stuff from scratch, so if you just get a feel for some of the sample scripts, you can modify and build on them to suit your own purposes.
One final word on ASP; it’s very similar to Visual Basic, so if you have some experience in that, it might be the way to go for you.
A document is not produced on the server end. The web is stateless in nature, meaning data and requests only exist as long as it takes to send a response back to whoever requested it, and it dies. If you set up a form, you can do something like create a document on the server, but normally it will just be loaded into a database or sent via e-mail to an e-mail address. However, it doesn’t just happen. Your data is sent to a location, like a script on a server, an action is performed on it, like writing it to a database or e-mailing it, and it dies.
There are plenty of PHP, Perl, Python, and ASP scripts out there that can do these things, so don’t reinvent the wheel. If you’re just looking for something simple and you aren’t interested in learning how to write server side programs, you can stick with something like Wufoo as mentioned above, which will allow you to embed your form into a page using an iframe.
Thanks for the help dudes. The book ICHTHEOSAURUSREX suggested is kinda pricey but I might have to bite the bullet and buy it because I really am into this Web building thing. As weird as it sounds I find it interesting and fun.
If anyone has anything else to pitch in please do so. Thanks.
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.