Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Form to CGI

Status
Not open for further replies.

igowi

Programmer
Sep 18, 2001
45
US
1. Two html pages has same script.
If I press one button on the a page, it shows another window with same action in the form tag as previous page.
When I send the form to the server, I need to take care of previous's form?

2. In the form, <INPUT TYPE=&quot;button&quot; ....>
It's sending this form to the cgi?
Some page has submit button, others doesn't have.
button is same role as submit?
 
The button COULD serve the same function as submit, but it would have to have an onClick=&quot;...&quot; action that executes the form submit command.

It's possible that the two pages calling the same script are doing so with a hidden variable that tells the script which function to perform. I do this regularly, especially on multiple-step forms. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks Tracy,

1.<INPUT TYPE=BUTTON VALUE=&quot;Add New Rule...&quot; onClick=openPage(&quot;editRule_0.html&quot;);>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;cgiaction&quot; VALUE=&quot;none&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;refresh_page&quot; VALUE=&quot;ruleTbl.html&quot;>
<INPUT TYPE=hidden NAME=&quot;removeRuleIndex&quot; VALUE=-1>
this is in the first page... and then it opens &quot;editRule_0.html page.
In this case, what string I should send to CGI script?


2. ....
<INPUT TYPE=BUTTON VALUE=&quot;Update&quot; onClick = doSubmit();>&nbsp;<INPUT TYPE=RESET VALUE=&quot;Reset&quot;>
in this case, when I send the &quot;Form&quot; to the server, as for button, I don't need to send any of string, right?
and also I don't send anything for reset.
what I am wondering is which input type I should send and which input type I don't send.

3. I am wondering how a CGI script works.
 
Web brower are sending cgi string (form) to CGI script.
The method is Post.
I thought I can send like this (cgiStr = &quot;name=value&name=value&quot;) I also think web browser is doing same. But, it's not working for my case. so, I want to know how it works in the POST case.
Every web browser is doing same things, right?
I want to know how to deal with FORM.
 
In case 1, all of the hidden fields are being sent to the cgi script (along with any non-hidden ones), so I don't know that you need to send anything else.

In case 2, I would guess that all that's happening is the the page is being submitted, with whatever fields are defined on that form (if any).

I would be curious as to what the openPage and doSubmit functions do.

A reset button never calls a script, it simply resets all field values to the original values. It's used to clear a form and start over.

How a cgi script works can be a long discussion, but I can give you a very abbreviated and simplified version.

First let me explain that CGI stands for Common Gateway Interface. It doesn't describe the language the program is written in, just the way the program interacts with the browser.

Here's what happens when a web page form is submitted:

All text fields, hidden fields, checkboxes, etc. in the form
have their values &quot;encoded&quot; so that spaces and special characters are converted to normal characters (for example, space is converted to %20). This is a holdover from times when special characters caused more problems than they do now.

The field names and values are put togeter into a string, with the format: name=value&name=value&name=value

The program specified in the action clause is called. The string of names and values is passed to the program (how isn't really important for this simple discussion).

The program &quot;takes apart&quot; the string of names and values, and uses those to do whatever it needs to do. This could be sending an email, updating a database, creating a new page, or almost anything else. The main thing to remember is that all this is done on the SERVER, not on your PC. A cgi progam cannot directly affect your PC.

The program must then send something back to the browser that it understands. This could be an image, a web page, a command to go to another web page, or a few other things.

That's the really short version of CGI.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thank you so much.

in the case 1, there is no &quot;submit&quot; in this page. The button makes open another page and the page which is opened has submit button.
What I am wondering is that the CGI script could expect both first page's form and second page's form at the same time.
I should send two forms to the script at once?



 
If the first page is simply opening the page, it must be somehow passing the data from the form to that page. There really isn't any good way to submit two forms at once, so it appears that the data from both forms is being combined into one, and submitted from the second form.

It's hard to be sure exactly what's going on without seeing what the two javascript functions do. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
After sending the form, what can I check about the cgi string? I can check the the string's length, right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top