more useful options | |
PerlMonks |
Re: How do I get data from a web form (the correct way)?by andye (Curate) |
on Dec 11, 2001 at 18:07 UTC ( [id://130927]=note: print w/replies, xml ) | Need Help?? |
Hi Monolith-0, you sound (understandably) frustrated. I'll try and clear things up a little.
First, you need to have the CGI.pm module installed. You almost certainly do already, as it comes as standard (I believe). Second, you need to use it as part of your script. There are two ways of doing this, the object-oriented style, and the 'normal' style. I'll show you examples of both. You need to make your HTML form. This is just a normal form, so I won't go into it - except to say that the action of the form should be the URL of your script.
Now, examples. The CGI.pm docs are here: and OO format: I prefer the OO format, but you can use either. Note also that you don't have to use the output functions (e.g. $q->h1('hello world') in order to use the input functions (e.g.$q->param('foo')) So, the most basic example of parsing form input would be: assuming that the HTML form has an input field called "cheese", e.g. <input type="text" name="cheese">
If you need to copy your parameters into a hash, then have a look at this part of the CGI.pm documentation: Further answers can be found in the CGI.pm documentation and in O'Reilly's CGI Programming with Perl (Scott Guelich et al).
Hope that helps,
In Section
Seekers of Perl Wisdom
|
|