Simple stateful web page using Perl

C

carlg

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
 
D

David Dorward

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

mbstevens

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
 
T

Toby Inkster

carlg said:
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; }
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top