HighDots Forums  

Newbie question about "submit"

alt.html alt.html


Discuss Newbie question about "submit" in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Smith
 
Posts: n/a

Default Newbie question about "submit" - 11-01-2003 , 08:34 AM






I have a neophyte question regarding what really gets sent out once I
click a submit button in a form. For example,
(http://www.webcom.com/~webcom/html/t...ms/start.shtml)

< FORM METHOD=POST
ACTION="http://www.webcom.com/cgi-bin/form" >

Enter your name:
< INPUT NAME=your_name >
< INPUT TYPE=submit VALUE="Test this form" >
< /FORM >

Suppose I enter "John" into the name field and click on the button,
what exactly is the text that gets sent back to the server? I tried
"http://www.webcom.com/cgi-bin/form?John", but the server returns an
error message. I'd like to the correct syntax for this.

Also, in the case where a form contains multiple text fields, radio
buttons, drop lists, etc, what is the syntax for encoding all these
input that's submitted to the server? A link to an on-line tutorial
would be appreciated.

Reply With Quote
  #2  
Old   
Hywel Jenkins
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 09:11 AM






In article <144f1687.0311010534.17bd68d4 (AT) posting (DOT) google.com>, necm500
@yahoo.com says...
Quote:
I have a neophyte question regarding what really gets sent out once I
click a submit button in a form. For example,
(http://www.webcom.com/~webcom/html/t...ms/start.shtml)

FORM METHOD=POST
ACTION="http://www.webcom.com/cgi-bin/form"

Enter your name:
INPUT NAME=your_name
INPUT TYPE=submit VALUE="Test this form"
/FORM

Suppose I enter "John" into the name field and click on the button,
what exactly is the text that gets sent back to the server? I tried
"http://www.webcom.com/cgi-bin/form?John", but the server returns an
error message. I'd like to the correct syntax for this.
http://www.webcom.com/cgi-bin/form?your_name=John

Your form is using POST, so your script (/cgi-bin/form) may choke on the
GET you're typing into your browser.

Quote:
Also, in the case where a form contains multiple text fields, radio
buttons, drop lists, etc, what is the syntax for encoding all these
input that's submitted to the server?
Why would you need to encode them - the browser will do that for you.


Quote:
A link to an on-line tutorial
would be appreciated.
http://www.google.com/

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php


Reply With Quote
  #3  
Old   
Stan Brown
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 09:59 AM



In article <MPG.1a0dcf74c0c22fd39897b1 (AT) news (DOT) individual.net> in
comp.infosystems.www.authoring.html, Hywel Jenkins
<hyweljenkins (AT) hotmail (DOT) com> wrote:
Quote:
A link to an on-line tutorial
would be appreciated.

http://www.google.com/
That's like saying "Library of Congress" when someone asks you to
recommend a book on the life and times of Gladstone.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/


Reply With Quote
  #4  
Old   
Eric Bohlman
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 10:25 AM



Stan Brown <the_stan_brown (AT) fastmail (DOT) fm> wrote in
news:MPG.1a0d9440ef48b7fe98b677 (AT) news (DOT) odyssey.net:

Quote:
In article <MPG.1a0dcf74c0c22fd39897b1 (AT) news (DOT) individual.net> in
comp.infosystems.www.authoring.html, Hywel Jenkins
hyweljenkins (AT) hotmail (DOT) com> wrote:

A link to an on-line tutorial
would be appreciated.

http://www.google.com/

That's like saying "Library of Congress" when someone asks you to
recommend a book on the life and times of Gladstone.
True. What the OP wants is "HTTP tutorial".


Reply With Quote
  #5  
Old   
Toby A Inkster
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 11:36 AM



John Smith wrote:

Quote:
FORM METHOD=POST
ACTION="http://www.webcom.com/cgi-bin/form"
Enter your name:
INPUT NAME=your_name
INPUT TYPE=submit VALUE="Test this form"
/FORM

Suppose I enter "John" into the name field and click on the button,
what exactly is the text that gets sent back to the server? I tried
"http://www.webcom.com/cgi-bin/form?John", but the server returns an
error message. I'd like to the correct syntax for this.
If it were a GET request (rather than a POST request) it would look like
this:

http://www.webcom.com/cgi-bin/form?your_name=John

But POST requests are different. The variables aren't tacked onto the URL
and are sent by other means. Find an HTTP tutorial for more details.

Quote:
Also, in the case where a form contains multiple text fields, radio
buttons, drop lists, etc, what is the syntax for encoding all these
input that's submitted to the server?
Consider the following form:

<form action="myscript.cgi" method="GET">
<fieldset>
<legend>Personal Details</legend>
<label><input name="name1"> Given Name</label><br>
<label><input name="name2"> Family Name</label><br>
<label><input name="sex" value="m" type="radio" checked="checked">
Male</label>
<label><input name="sex" value="f" type="radio"> Female</label><br>
<label>
<select name="age">
<option value="range1">Under 18</option>
<option value="range2">18-25</option>
<option value="range3">26-35</option>
<option value="range4">36-49</option>
<option value="range5">50+</option>
</select>
Age
</label><br>
<label><input name="spam1" checked="checked" type="checkbox">
Sell my details to spammers</label><br>
<label><input name="spam2" type="checkbox">
Sell my details to <strong>evil</strong> spammers</label><br>
</fieldset>
</form>

If I fill in my name, choose "Male" from the radio buttons, choose my age
(I'm 23) and leave the checkboxes as they are, the following URL will be
submitted:

myscript.cgi?name1=Toby&name2=Inkster&sex=m&age=ra nge2&spam1=on

Note: no "spam2=off" is submitted.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?id=132



Reply With Quote
  #6  
Old   
Toby A Inkster
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 11:46 AM



Toby A Inkster wrote:

Quote:
label><input name="spam2" type="checkbox"
Sell my details to <strong>evil</strong> spammers</label><br
/fieldset
/form
.... and a "submit" button might have been nice. ;-)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?id=132



Reply With Quote
  #7  
Old   
Hywel Jenkins
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 02:01 PM



In article <MPG.1a0d9440ef48b7fe98b677 (AT) news (DOT) odyssey.net>,
the_stan_brown (AT) fastmail (DOT) fm says...
Quote:
In article <MPG.1a0dcf74c0c22fd39897b1 (AT) news (DOT) individual.net> in
comp.infosystems.www.authoring.html, Hywel Jenkins
hyweljenkins (AT) hotmail (DOT) com> wrote:

A link to an on-line tutorial
would be appreciated.

http://www.google.com/

That's like saying "Library of Congress" when someone asks you to
recommend a book on the life and times of Gladstone.
With Google, however, you can show the smallest hint of common sense and
type "form tutorial" and get pretty much straight to what you need, same
if you search for "life and times of Gladstone".

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php


Reply With Quote
  #8  
Old   
Stan Brown
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 05:21 PM



In article <MPG.1a0e135c2014a6aa9897b5 (AT) news (DOT) individual.net> in
comp.infosystems.www.authoring.html, Hywel Jenkins
<hyweljenkins (AT) hotmail (DOT) com> wrote:
Quote:
In article <MPG.1a0d9440ef48b7fe98b677 (AT) news (DOT) odyssey.net>,
the_stan_brown (AT) fastmail (DOT) fm says...
In article <MPG.1a0dcf74c0c22fd39897b1 (AT) news (DOT) individual.net> in
comp.infosystems.www.authoring.html, Hywel Jenkins
hyweljenkins (AT) hotmail (DOT) com> wrote:

A link to an on-line tutorial
would be appreciated.

http://www.google.com/

That's like saying "Library of Congress" when someone asks you to
recommend a book on the life and times of Gladstone.

With Google, however, you can show the smallest hint of common sense and
type "form tutorial" and get pretty much straight to what you need, same
if you search for "life and times of Gladstone".
And anyone who knows how to use a search engine already knows of the
existence of a search engine, so all your reply did was waste
bandwidth.

What Google (and the Library of Congress) won't tell you is which
source is better than another. That would have been worth
mentioning; otherwise better to keep silent.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/


Reply With Quote
  #9  
Old   
John Smith
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 07:01 PM



Toby A Inkster <UseTheAddressInMySig (AT) deadspam (DOT) com> wrote

Quote:
John Smith wrote:

FORM METHOD=POST
ACTION="http://www.webcom.com/cgi-bin/form"
Enter your name:
INPUT NAME=your_name
INPUT TYPE=submit VALUE="Test this form"
/FORM

Suppose I enter "John" into the name field and click on the button,
what exactly is the text that gets sent back to the server? I tried
"http://www.webcom.com/cgi-bin/form?John", but the server returns an
error message. I'd like to the correct syntax for this.

If it were a GET request (rather than a POST request) it would look like
this:

http://www.webcom.com/cgi-bin/form?your_name=John

But POST requests are different. The variables aren't tacked onto the URL
and are sent by other means. Find an HTTP tutorial for more details.
Thanks for the tips, but
"http://www.webcom.com/cgi-bin/form?your_name=John" doesn't work,
guess it must use POST then.

I briefly looked up the dif between "get" and "post", it seems that
the latter doesn't encode submission in url form, which begs the
question: how does it send data anyway? what data does it actually
send? in encrypted form? do the data fromat differs from one form from
another depending on the specific implementation of the programmer?
Can one glean some hints by examining the html code of the submission
page?

The reason I'm interested is that I'm curious about if it's possible
to automate the submission process by directly sending requests to the
remote server so that no human is needed to click the "submit" button
for every submission. It'd be very neat if I can do this even with
forms using "post".

Thanks again for the help.

Quote:
Also, in the case where a form contains multiple text fields, radio
buttons, drop lists, etc, what is the syntax for encoding all these
input that's submitted to the server?

Consider the following form:

form action="myscript.cgi" method="GET"
fieldset
legend>Personal Details</legend
label><input name="name1"> Given Name</label><br
label><input name="name2"> Family Name</label><br
label><input name="sex" value="m" type="radio" checked="checked"
Male</label
label><input name="sex" value="f" type="radio"> Female</label><br
label
select name="age"
option value="range1">Under 18</option
option value="range2">18-25</option
option value="range3">26-35</option
option value="range4">36-49</option
option value="range5">50+</option
/select
Age
/label><br
label><input name="spam1" checked="checked" type="checkbox"
Sell my details to spammers</label><br
label><input name="spam2" type="checkbox"
Sell my details to <strong>evil</strong> spammers</label><br
/fieldset
/form

If I fill in my name, choose "Male" from the radio buttons, choose my age
(I'm 23) and leave the checkboxes as they are, the following URL will be
submitted:

myscript.cgi?name1=Toby&name2=Inkster&sex=m&age=ra nge2&spam1=on

Note: no "spam2=off" is submitted.

Reply With Quote
  #10  
Old   
Eric Bohlman
 
Posts: n/a

Default Re: Newbie question about "submit" - 11-01-2003 , 08:07 PM



necm500 (AT) yahoo (DOT) com (John Smith) wrote in
news:144f1687.0311011601.5a4fd84 (AT) posting (DOT) google.com:

Quote:
I briefly looked up the dif between "get" and "post", it seems that
the latter doesn't encode submission in url form, which begs the
question: how does it send data anyway? what data does it actually
send? in encrypted form? do the data fromat differs from one form from
another depending on the specific implementation of the programmer?
Can one glean some hints by examining the html code of the submission
page?
No. In order to understand the difference, you need to understand how HTTP
requests work. Teaching that is rather beyond the scope of a Usenet post,
but there are plenty of tutorials available if you know that what you're
looking for is the details of the HTTP protocol.

In a nutshell, the difference is that a GET request is made to the URL
specified in the form's action with the parameters appended to it as part
of a query string (which begins with a question mark), whereas a POST
request is made to the unadorned URL, and the parameters are sent as part
of the body of the request. That won't make much sense to you until you
get somewhat familiar with HTTP.

Quote:
The reason I'm interested is that I'm curious about if it's possible
to automate the submission process by directly sending requests to the
remote server so that no human is needed to click the "submit" button
for every submission. It'd be very neat if I can do this even with
forms using "post".
Yes, that can be done quite easily. If, for example, you were doing it in
Perl, you'd want to use the LWP::UserAgent module, which internally
understands the differences between the two requests and handles them
appropriately. Other languages have similar libraries/modules, and you
would be *strongly* advised to use them rather than trying to do everything
yourself at the TCP level; there are lots of tricky aspects to what looks,
on the surface, like a simple protocol, and the authors of those libraries
have already dealt with them and tested their code. This is one wheel that
should not be reinvented.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.