Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Newbie question about "submit"

Reply
Thread Tools

Newbie question about "submit"

 
 
John Smith
Guest
Posts: n/a
 
      11-01-2003
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
 
 
 
 
Hywel Jenkins
Guest
Posts: n/a
 
      11-01-2003
In article <(E-Mail Removed) >, necm500
@yahoo.com says...
> 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.

> 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.


> 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
 
 
 
 
Stan Brown
Guest
Posts: n/a
 
      11-01-2003
In article <(E-Mail Removed)> in
comp.infosystems.www.authoring.html, Hywel Jenkins
<(E-Mail Removed)> 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.

--
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
 
Eric Bohlman
Guest
Posts: n/a
 
      11-01-2003
Stan Brown <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> In article <(E-Mail Removed)> in
> comp.infosystems.www.authoring.html, Hywel Jenkins
> <(E-Mail Removed)> 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
 
Toby A Inkster
Guest
Posts: n/a
 
      11-01-2003
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.

> 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
 
Toby A Inkster
Guest
Posts: n/a
 
      11-01-2003
Toby A Inkster wrote:

> <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
 
Hywel Jenkins
Guest
Posts: n/a
 
      11-01-2003
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> In article <(E-Mail Removed)> in
> comp.infosystems.www.authoring.html, Hywel Jenkins
> <(E-Mail Removed)> 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
 
Stan Brown
Guest
Posts: n/a
 
      11-01-2003
In article <(E-Mail Removed)> in
comp.infosystems.www.authoring.html, Hywel Jenkins
<(E-Mail Removed)> wrote:
>In article <(E-Mail Removed)>,
>(E-Mail Removed) says...
>> In article <(E-Mail Removed)> in
>> comp.infosystems.www.authoring.html, Hywel Jenkins
>> <(E-Mail Removed)> 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
 
John Smith
Guest
Posts: n/a
 
      11-02-2003
Toby A Inkster <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) >...
> 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.

>
> > 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
 
Eric Bohlman
Guest
Posts: n/a
 
      11-02-2003
(E-Mail Removed) (John Smith) wrote in
news:(E-Mail Removed) m:

> 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.

> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VONAGE Newbie w/newbie question New_kid@nowhere.new VOIP 0 08-11-2007 01:40 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
newbie: cisco vlan newbie question No Spam Cisco 3 06-07-2004 10:02 AM
dumb newbie question (or newbie dumb question) Jerry C. Perl Misc 8 11-23-2003 04:11 AM
Newbie! I'm a newbie! What's wrong with this program? Id0x Python 4 07-20-2003 11:40 PM



Advertisments