Posted by David Dorward on 09/15/06 14:44
carlg@libertybasic.com 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.
Navigation:
[Reply to this message]
|