Newbie question about "submit"

Discussion in 'HTML' started by John Smith, Nov 1, 2003.

  1. John Smith

    John Smith Guest

    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/tutor/forms/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.
     
    John Smith, Nov 1, 2003
    #1
    1. Advertising

  2. In article <>, 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/tutor/forms/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
     
    Hywel Jenkins, Nov 1, 2003
    #2
    1. Advertising

  3. John Smith

    Stan Brown Guest

    In article <> in
    comp.infosystems.www.authoring.html, Hywel Jenkins
    <> 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/
     
    Stan Brown, Nov 1, 2003
    #3
  4. John Smith

    Eric Bohlman Guest

    Stan Brown <> wrote in
    news::

    > In article <> in
    > comp.infosystems.www.authoring.html, Hywel Jenkins
    > <> 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".
     
    Eric Bohlman, Nov 1, 2003
    #4
  5. 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=range2&spam1=on

    Note: no "spam2=off" is submitted.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
     
    Toby A Inkster, Nov 1, 2003
    #5
  6. 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
     
    Toby A Inkster, Nov 1, 2003
    #6
  7. In article <>,
    says...
    > In article <> in
    > comp.infosystems.www.authoring.html, Hywel Jenkins
    > <> 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
     
    Hywel Jenkins, Nov 1, 2003
    #7
  8. John Smith

    Stan Brown Guest

    In article <> in
    comp.infosystems.www.authoring.html, Hywel Jenkins
    <> wrote:
    >In article <>,
    > says...
    >> In article <> in
    >> comp.infosystems.www.authoring.html, Hywel Jenkins
    >> <> 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/
     
    Stan Brown, Nov 1, 2003
    #8
  9. John Smith

    John Smith Guest

    Toby A Inkster <> wrote in message news:<>...
    > 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=range2&spam1=on
    >
    > Note: no "spam2=off" is submitted.
     
    John Smith, Nov 2, 2003
    #9
  10. John Smith

    Eric Bohlman Guest

    (John Smith) wrote in
    news::

    > 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.
     
    Eric Bohlman, Nov 2, 2003
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    1
    Views:
    1,718
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,237
    Ghafran Abbas
    Oct 12, 2004
  3. The Crow
    Replies:
    2
    Views:
    4,406
    Bruce Barker
    Sep 27, 2005
  4. Megha Vishwanath
    Replies:
    2
    Views:
    9,846
    tutorialsmaster
    Oct 2, 2009
  5. Replies:
    2
    Views:
    6,246
Loading...

Share This Page