On Tue, Mar 22, 2011 at 1:05 PM, Geospectrum <alan.hunt...@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)

Reply via email to