fuzzyping has asked for the wisdom of the Perl Monks concerning the following question:
and the login sub...#!/usr/bin/perl use strict; no strict 'vars'; use CGI qw(:standard); use CGI::Session::DB_File; use Crypt::PasswdMD5; use DBI; $| = 1; require "/var/www/cgi-bin/lunchforum/includes/errors.pl"; require "/var/www/cgi-bin/lunchforum/includes/login.pl"; require "/var/www/cgi-bin/lunchforum/includes/main_forum.pl"; require "/var/www/cgi-bin/lunchforum/includes/newaccount.pl"; $title = "Digex Lunch Forum"; $dbpath = "/var/www/cgi-bin/nobody/lunchforum"; $database = "dlforum"; $server = "localhost"; $dbuser = "dlfuser"; $dbpasswd = "m1ck3yd335"; $cgi = CGI->new; $sid = $cgi=>cookie('hungry') || undef; $session = new CGI::Session::DB_File($sid, {Filename=>"$dbpath/lunchfo +rum.db", LockDirectory=>"$dbpath/"}); $sid ||=$session->id; $cookie = $cgi->cookie(-name=>'hungry', -value=>$sid, -expires=>'+30m' +); $dbh = DBI->connect("DBI:mysql:$database:$server","$dbuser","$dbpasswd +"); if (param('newaccount')) { &newaccount_form } elsif (param('newlogin')) { $username = &login('newuser'); &newaccount($username); } elsif (param('oldlogin')) { $username = &login; &main_handler($username) } elsif (!(param('logged'))) { &login_form } else { $username = ($session->param('username') || "duh"); &main_handler($username) } $dbh->disconnect; sub main_handler { $username = shift; &page_navbar($username); &page_header($username); &page_body($username); } sub print_header { print $cgi->header( -type=>'text/html', -cookie=>$cookie, -start_html=>$title) }
sub login_form { &print_header; print "<center>", $cgi->start_form, $cgi->h1($title), $sid,br, "Welcome to the Digex Lunch Forum.",br, "Please login below or check \"New Account\"",br, "to sign up for our group and receive your premier ben +efits.",br,br, "<table><tr><td>Username </td><td>", $cgi->textfield('username'),"</td></tr><tr><td>Passwor +d </td><td>", $cgi->password_field('secret'),"</td></tr></table>",br +, $cgi->checkbox_group(-name=>'newaccount', -value=>'New + Account'),br,br, $cgi->submit(-name=>'oldlogin', -value=>'Next'), " ", $cgi->defaults('Clear'),"</center>", $cgi->end_form, $cgi->end_html; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: More problems with CGI::Session
by Juerd (Abbot) on Mar 14, 2002 at 22:58 UTC | |
by fuzzyping (Chaplain) on Mar 14, 2002 at 23:03 UTC | |
by theguvnor (Chaplain) on Mar 15, 2002 at 02:57 UTC | |
by oubiwann (Sexton) on Mar 15, 2002 at 05:38 UTC | |
|
Re: More problems with CGI::Session
by oubiwann (Sexton) on Mar 14, 2002 at 22:57 UTC | |
by fuzzyping (Chaplain) on Mar 14, 2002 at 23:02 UTC | |
by oubiwann (Sexton) on Mar 14, 2002 at 23:47 UTC | |
|
Re: More problems with CGI::Session
by Anonymous Monk on Sep 08, 2002 at 03:38 UTC |