[prev in list] [next in list] [prev in thread] [next in thread]
List: cgiapp
Subject: CGI App newbie
From: Stelian Iancu <stelian.iancu () gmx ! net>
Date: 2002-11-25 16:46:56
[Download RAW message or body]
Hello!
I have this little CGI::Application using HTML::Template. Here is a
snippet of code from it:
package BTS;
use base 'CGI::Application';
sub setup {
my $self = shift;
$self->header_type('header');
$self->start_mode('homepage');
$self->tmpl_path('/var/www/html/bts/');
$self->mode_param('rm');
$self->run_modes(
'homepage' => 'homepage_method',
'login' => 'login_method',
);
}
sub homepage_method {
my $self = shift;
my $homepage = $self->load_tmpl('homepage.tmpl');
$homepage->param(OK => 1);
my $q = $self->query();
my $output = '';
$output .= $q->start_html;
$output .= $homepage->output;
$output .= $q->end_html;
return $output;
}
sub login_method {
my $self = shift;
[snip]
# here is a sample code, not the actual code
if (login failed) {
my $homepage = $self->load_tmpl('homepage.tmpl');
$homepage->param(OK => 0);
$output .= $homepage->output;
return $output;
}
}
1;
This is the homepage.tmpl:
<table border="0">
<tr><td><TMPL_INCLUDE NAME="menu.tmpl"></td>
<td valign="top">
<TMPL_IF NAME="OK">
<TMPL_INCLUDE NAME="homepage_middle.tmpl">
<TMPL_ELSE>
<TMPL_INCLUDE NAME="login_failed.tmpl">
</TMPL_IF>
</td>
</tr>
</table>
homepage_middle.tmpl contains a message showing that the login is
successfull and login_failed.tmpl contains a message showing that login
failed. So, at the beginning, I load homepage.tmpl, I put the OK param
to 1, so homepage_middle.tmpl is also loaded. When I push the login
button, the action of the form is index.pl?rm=login. So the login_method
is executed (no?). Here, I set the OK param to 0 and I expect to see the
login failed message. Instead, the old homepage_middle gets loaded
again. Also, if I put the rm param as a hidden field in the form, i get
an Internal server error. The strange thing is that if I execute the
script index.pl from the command line, I get the expected result for
each case (login correct and incorrect). So, please tell me where the
problem is.
Sorry for the length of this message.
--
Regards,
Stelian I.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic