[Novalug] question about behavior of cgi script from html form

Jeff Stoner leapfrog@freeshell.org
Fri Sep 4 13:11:05 EDT 2009


On Fri, 4 Sep 2009, Bonnie Dalzell wrote:

> I give each reservation a different record number when it is made.

Is this reservation number generated when the form is loaded or when the 
data in the form is submitted?

> However sometimes I wish to repeat most of the information entered in the 
> form and only change a couple of things such as the dog's name and sex.

> I am not expecting someone to debug my script for me, I am just trying to 
> figure out if the problem is due to my misunderstanding of how browsers and 
> cgi scripts interact.

Remember, HTTP is stateless - each connection is 100% separate from the 
next. This means if you want the appearance of state (some form fields 
prepopulated with values from the prior form submission) then you have to 
write your cgi to do that (or use AJAX.) Since each request is separate, 
you need a way of identifying requests belonging to a particular user 
- this is usually done using a cookie that contains a session number 
(though there are other ways.)

The cgi script itself needs to be aware of prior state. If the user has 
submitted a reservation request in the past, then grab some of the data 
from that request and generate the form with those fields prepopulated, 
otherwise, generate the form with all blank fields.


--Jeff

"You cannot unsay a cruel word." - Unknown




More information about the Novalug mailing list