Simple stateful web page using Perl

Discussion in 'HTML' started by carlg@libertybasic.com, Sep 15, 2006.

  1. Guest

    Sorry if this is the wrong place for this question, but the Perl people
    tell me it's a cgi programming question. I looked for a cgi
    programming group but couldn't find one, so I hope this is a good place
    to ask the question. ;-)

    How would I write a simple web app in Perl+cgi that has state? Let's
    say I just want to have a web page that has an input field, an Accept
    button and a Clear button. Whenever I type some text into the field
    and click on Accept it concatenates the text in the field with an
    existing string and displays it on the web page. So I can submit a few

    words one at a time and make a sentence. Clicking the Clear button
    lets me start over.

    -Carl Gundel, author of Liberty BASIC
    http://www.libertybasic.com
     
    , Sep 15, 2006
    #1
    1. Advertising

  2. wrote:
    > How would I write a simple web app in Perl+cgi that has state? Let's
    > say I just want to have a web page that has an input field, an Accept
    > button and a Clear button. Whenever I type some text into the field
    > and click on Accept it concatenates the text in the field with an
    > existing string and displays it on the web page. So I can submit a few
    > words one at a time and make a sentence. Clicking the Clear button
    > lets me start over.


    This breaks down into four or five tasks.

    (1) Handing the submission. Look at CGI.pm for reading form data.

    (2) Deciding to append or clear. Only the clicked submit button will be
    a successful control, so give them the same name and test the value on
    the server.

    (3) Storing the data. You can do this to a database (look at DBI and
    possible DBIx::Class) or a flat file.

    (4) Reading the data (as 3)

    (5) If you want multiple users to have their own areas to work with,
    then you need to identify the users. CGI::Session is probably a good
    place to start.
     
    David Dorward, Sep 15, 2006
    #2
    1. Advertising

  3. mbstevens Guest

    On Fri, 15 Sep 2006 07:09:06 -0700, carlg wrote:

    > Sorry if this is the wrong place for this question, but the Perl people
    > tell me it's a cgi programming question. I looked for a cgi programming
    > group but couldn't find one, so I hope this is a good place to ask the
    > question. ;-)
    >
    > How would I write a simple web app in Perl+cgi that has state? Let's say
    > I just want to have a web page that has an input field, an Accept button
    > and a Clear button. Whenever I type some text into the field and click on
    > Accept it concatenates the text in the field with an existing string and
    > displays it on the web page. So I can submit a few
    >
    > words one at a time and make a sentence. Clicking the Clear button lets
    > me start over.


    In order of my own preferance:
    1) Let cgi.pm handle it (read docs on cgi.pm)
    2) set a cookie
    3) generate hidden fields in a web page
     
    mbstevens, Sep 15, 2006
    #3
  4. Toby Inkster Guest

    carlg wrote:

    > How would I write a simple web app in Perl+cgi that has state? Let's
    > say I just want to have a web page that has an input field, an Accept
    > button and a Clear button. Whenever I type some text into the field
    > and click on Accept it concatenates the text in the field with an
    > existing string and displays it on the web page. So I can submit a few
    > words one at a time and make a sentence. Clicking the Clear button
    > lets me start over.


    Method 1: use cookies.

    Method 2: use hidden input fields to pass around data.

    Preferred method: if (test for cookies) { method 1; } else { method 2; }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Sep 17, 2006
    #4
    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. Marc Floessel
    Replies:
    0
    Views:
    437
    Marc Floessel
    Jul 9, 2004
  2. Sanjay Gupta

    stateful Java web services

    Sanjay Gupta, Oct 5, 2006, in forum: Java
    Replies:
    1
    Views:
    301
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Oct 6, 2006
  3. Replies:
    0
    Views:
    448
  4. Replies:
    0
    Views:
    253
  5. Simple stateful web page?

    , Sep 14, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    79
    David Squire
    Sep 14, 2006
Loading...

Share This Page