Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Need some Help with Form

by Sleepaholic88 (Novice)
on Sep 30, 2003 at 01:38 UTC ( [id://295160]=perlquestion: print w/replies, xml ) Need Help??

Sleepaholic88 has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I made a form (http://www.smmovies.netfirms.com/form.html) that people can submit movie reviews to, and it send me the results (using FormMail.pl). Now, i want it to create a page automatically (or semi-automatically) from the results.

Here is what the e-mail would look like:
Below is the result of your feedback form. It was submitted by () on Monday, September 29, 2003 at 21:30:37 ---------------------------------------------------------- reviewer: Simon movie: Jian Gui genre: Foreign rating: R director: Chun, Oxide Pang; Pang, Danny. cast: Lee, Angelica; Chou, Lawrence. length: 1 Hour, 38 Min. review1: The premise of this Hong Kong movie is that a 19 year old gir +l, Mun (Angelica Lee) gets a cornea transplant, and with her new eyes, she ca +n see more than she even thought existed: Ghosts! She convinces Dr. Wah (Lawrence + Chou) of her visions, and they take a quest to find the previous "owner" of the + eyes. review2: This Cantonese movie is a prime example of foreign horror (a. +k.a Horreign) films. Although a mixture of films like "The Sixth Sense" (t +he theme of the girl being able to see ghosts), and "Final Destination" (the th +eme of the girl being able to predict accidents/deaths), this movie is by far bet +ter than both of those. This movie stars a number of young, inexperienced actor +s and actresses, but seem to have been acting their entire lives. For it's g +ood script and acting, this movie gains a number of stars, also adding to it's sc +ore is the great horror which this movie brings to the viewer. Also, this movie i +s one of those movies that are made for the viewer to think, to a good music sc +ore, no less. Overall, this movie loses a mere 2 stars for unoriginality. stars: 8 ----------------------------------------------------------

Here's an example of what the page should look like at the end: http://www.geocities.com/smmovies2004/JianGui.html (the updating of the menu seems hard, because it has to update on every page) so you can leave that out if you choose.

Any ideas of how I can accomplish this? What modules to use? Anything? All help is GREATLY appreciated!

Replies are listed 'Best First'.
Re: Need some Help with Form
by jonadab (Parson) on Sep 30, 2003 at 02:01 UTC

    The first thing I'll do is answer your last (concrete) question: you asked what modules to use. There's a module called (conveniently) CGI, which is just for CGI scripts. Since you seem to be new to CGI, that module may be the way for you to go. (There are other options, of course, but CGI is a popular one.) There are also various books and online tutorials for using it, which is a good reason to consider it. (I don't use it, because I roll my own, but I also read RFC documents; if you're not that kind of geek, you may want to use the module.)

    For sending mail, you may want to consider Mail::Mailer or Mail::Send. These are considered better than formmail.pl, partly for reasons of security, and partly for reasons of coding style.

    update: added links, and mail-sending info.

    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
Re: Need some Help with Form
by Cody Pendant (Prior) on Sep 30, 2003 at 02:16 UTC
    The short answer is, you should use CGI.pm, and you should probably use HTML::Template, but you shouldn't "create a page".

    You should store the results in some kind of file, or better, a database, and you should construct the page at the time the user clicks on the link.

    So for instance, say this user submission creates a file called "12345.txt" which had the review and the details in it.

    Then you'd write a script called showreview.pl and it would be called like "showreview.pl?id=12345". Grab that id number in your script, (you can use CGI.pm to do that) open the file with that name, read the contents, and merge the contents with some HTML that you keep somewhere else (you can use HTML::Template to do that).

    Doing it this way you can redesign your site instantly by redesigning the HTML file, which is an important principle -- keeping you data in one place and your formatting in another.

    How's that to start you off?

    P.S. Tom Cruise has optioned the rights to that movie. See it now before the lame US remake. See also "The Ring", "Vanilla Sky" etc etc.



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
Re: Need some Help with Form
by Cody Pendant (Prior) on Sep 30, 2003 at 02:20 UTC
    Oh yeah.

    Forgot to say, very soon you're going to need an administration interface so you can weed out obscene or meaningless content...



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
      And maybe write html that works in browsers other than IE. Your demo page breaks pretty badly in safari.


      -Waswas
sleepaholic88@hotmail.com
by Sleepaholic88 (Novice) on Sep 30, 2003 at 01:50 UTC
    NOTE...
    I changed the form a bit by adding

    value=" "

    to each text field so that all parts of the form are in the e-mail.
Re: Need some Help with Form
by bradcathey (Prior) on Sep 30, 2003 at 02:08 UTC
    Of course, CGI is a no-brainer, but after you get a handle on that, take a look at HTML::Template module. You can design the page in HTML, keep it in HTML, but fill in the data using the H::T placeholders. Powerful and easy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://295160]
Approved by LazerRed
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-03-28 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found