Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Think about Loose Coupling
 
PerlMonks  

Re: How do I write a CGI script with form validation?

by Gilimanjaro (Hermit)
on Aug 16, 2004 at 11:32 UTC ( #383262=note: print w/ replies, xml ) Need Help??


in reply to How do I write a CGI script with form validation?

For eCommerce applications I would definitely use sessions to store the state of the transaction. Whether you pass the session id using a http parameters or a cookie depends on whether you will be in a position to 'demand' site-compliance from your customers.

Furthermore, especially when forced to use plain cgi, I like to separate the entry, validation and processing into separate scripts with their respective templates. The validation script I usually create has no output of it's own, but redirects to either the form page (in case of problems) or the processing page (it it's all ok) after setting the appropriate 'validated' flag in the user's session store...

I would definitely read up on the HTTP protocol, and more specifically on GET/POST parameters and Cookies so you get more of a feel for the issues you'll be dealing with.

I wouldn't rely on JavaScript for validation, as users may have it disabled, and more importantly developing multi-browser compatible JavaScript is an art on it's own. If you do decide to use it, I'd try to find prefab snippets for your purpose, and I'd still do server-side validation for security reasons.


Comment on Re: How do I write a CGI script with form validation?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://383262]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-04-20 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls