I'm not sure I follow the problem. You said (code removed):
Hello Monks, I have a simple html form.(Month Day Year Title and Message) input fields are used.
When the form is submited the cgi script displays the variable information and formatting correctly.
At this point I wanted to be able to write the variables to a file or go back and continue editing. But I am still new to perl and I am having a lot of trouble.
I have not tried to run the code you posted, so I am not sure if what you ask is a problem in the code itself, or when it runs. Assuming the code runs ok,
- Is the problem you are having with the actual saving of the data to the file? If so, what error are you seeing? One common issue with writing to data files from a CGI is the ownership and read/write permissions on the data files and the directory they reside in.
- Is the issue with data being clobbered during submission? You may want to look at implementing some form of locking to prevent two submissions from walking over each other.
- Is the problem with having the values back in the form to be edited? My own limited experience has been to make scripts that keyed off a value returned by the submit to determine which processing to do, in order to also display the form with the elements' VALUE= lines filled in (for instance, having your Preview and Submit buttons have the same NAME= value, such as "dowhat", setting $action to some default value such as "donothing", then changing it to "add_event" only if defined($q->param('dowhat')) and it has the appropriate value-otherwise, if I read your code right, it should go ahead and display the form anew). If I read it correctly, it looks like you're using a bit of javascript to send them back a page on a "Continue", which in my limited understanding I would think would cause them to lose what they had typed.
- Is the issue something else? As I said, I wasn't sure from what you asked.
While I was a little concerned at seeing values in store_event() that had not been passed it, I realized the concern was more likely due to the time of night I was reading the posting and the likelyhood you had stripped the code down somewhat than just they not actually being defined in the code.
A look at Ovid's Web Programming Using Perl course, and tachyon's CGI Help Guide might give you some additional insight into the issue. CGI Programming with Perl and the Perl Cookbook may also prove helpful, as may other resources, such as the Tutorials section here and the comments of other monks.
Good luck with the problem. Hope this helped somewhat.
Update: (19 Oct 2002) In several private messages from others overnight, it was suggested to me several other sources which might also be of use, or that might be of use to others new to the site who may read this later. Mostly related to the asking of questions, they included:
To you, and to others who come after, I wish you good luck, and my thanks to those who messaged me regarding the additional information.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.