Newbie needs help

Hi am am setting up a small website and have set up formmail.pl to
create a way of people asking questions.

I'd like now to add a way of visitors to display a HTML page by
entering a number (invoice number) into a HTML form and then retrieve
a html page. So I create a html page called http://www.mysite/1234.html
and the user types in 1234 into the form and the page http://www.mysite/1234.html
is retrived and displayed.

I imagine I could use the perl script to create the full url and
display the page by conctenating the domain name, invoice number
and .html but I really have no idea about how to do this. Can I use
the GET method of the form? I am hoping someone can point me towards a
tutorial or offer up some snippets.

Thanks


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Geospectrum [ Di, 22 März 2011 18:05 ] [ ID #2056983 ]

Re: Newbie needs help

--20cf30025cde9637f9049f174616
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Mar 22, 2011 at 1:05 PM, Geospectrum <alan.huntley [at] geospectrum.co.uk
> wrote:

> Hi am am setting up a small website and have set up formmail.pl to
> create a way of people asking questions.
>
> I'd like now to add a way of visitors to display a HTML page by
> entering a number (invoice number) into a HTML form and then retrieve
> a html page. So I create a html page called http://www.mysite/1234.html
> and the user types in 1234 into the form and the page
> http://www.mysite/1234.html
> is retrived and displayed.
>
> I imagine I could use the perl script to create the full url and
> display the page by conctenating the domain name, invoice number
> and .html but I really have no idea about how to do this. Can I use
> the GET method of the form? I am hoping someone can point me towards a
> tutorial or offer up some snippets.
>
>
> lets go simple and then go pro here.

simple (bad) use cgi get. so www.example.com/script.pl?1234

and do something like (untested, should work):
my $page = $cgi->param( 'page' );
print $cgi->redirect( $page . ".html" );

however, you probably want to use template toolkit if you're doing simple
perl pages. personally, i use catalyst and javascript to render data (so i
don't do too much in template toolkit).

if you do catalyst, you might setup a model that looks something like this:
my $page = $c->req->param->{page};
$c->forware( "View::" . $page );

which would forward you to that tt view when you get that request. i don't
like either of these ways of doing it and if you wanted to do exactly as you
asked, just open a file handle and dump. though, my preference really is to
return json data and use js to render :)

also, this is more meta code than code - you need to do checking and what
not. i'm not sure if cgi.pm does anything to prevent me from doing:
www.example.com/script.pl?page=rm%20-rf%20<whatever the symbol is for
'/'>%20
which may do something like:
rm -rf / .html
(html wouldn't match but / would - not good)

--20cf30025cde9637f9049f174616--
Shawn Wilson [ Di, 22 März 2011 20:30 ] [ ID #2056984 ]

Re: Newbie needs help

>>>>> "Geospectrum" == Geospectrum <alan.huntley [at] geospectrum.co.uk> writes:

Geospectrum> Hi am am setting up a small website and have set up formmail.pl to
Geospectrum> create a way of people asking questions.

I'm so very much hoping that you're not using Matt Wright's original
formmail.pl, and instead using the one from NMS. Even Matt now tells
you to go get NMS:

http://www.scriptarchive.com/nms.html

Yes, Matt's a good guy... even he knows when he's been beaten. :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn [at] stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
merlyn [ Di, 22 März 2011 21:44 ] [ ID #2056986 ]
Perl » gmane.comp.lang.perl.beginners » Newbie needs help

Vorheriges Thema: Better Regrex
Nächstes Thema: upgraded Macports broke working Perl environment