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

Re: CGI form validation on submit

by benn (Vicar)
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://283540]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2018-05-20 13:01 GMT
Find Nodes?
    Voting Booth?