Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: CGI form validation on submit

by benn (Priest)
on Aug 13, 2003 at 13:26 UTC ( #283540=note: print w/ replies, xml ) Need Help??


in reply to CGI form validation on submit

I think you need to be a little clearer on the whole client-server communication thing. Basically, the deal is something like this.

  • Your browser requests something (say, a CGI script) from a server.
  • The server runs the requested script, and sends your browser the output - usually, a bunch of HTML / images etc. - stuff your browser knows how to render.
  • Included in that HTML may be Javascript (or JScript or similar) - something too that most browsers know how to cope with. Note that this script is generally not allowed to interact with any part of the client machine *other* than the browser.
  • If the HTML contains a form, the values entered are sent back to the server as a new request when the form is submitted. The server can examine this request and take appropriate action
Hopefully you can see from this model that your CGI script runs *on the server*, not the client. The client simply receives the output, renders it, optionally uses client-side-scipting to process it (document.write, onSubmit etc.) and sends it back.

As an aside, you should never *rely* on client-side scripting to validate a form. Having it as an extra check before submission is fine, but the server script should do this also to cater for those who don't run JS / hand craft forms / hack your HTML. Many many JS shopping cart systems have learnt this to their cost :)

Hope this helps, Ben.


Comment on Re: CGI form validation on submit

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-09-22 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (182 votes), past polls