in reply to Creating a login page

A point with regard to your form generation:

The CGI::header function (e.g. $query->header()) is what is responsible for spitting out the "content-type: text/html" things, not the page title. The standard way of using the Header function is:

print $query->header();

...it will send "text/html" if nothing is specified, or you can send your own content headers by "$query->header ('image/gif')" to send a GIF image header, etc.

As for the login process, what you'll probably want to do is have the form contain the players names list, a pair of radio buttons to select mother or father and the name of the parental in qestion and verify them all in one fell swoop, whereupon you'll probably want to assign them a cookie (with CGI::Cookie or somesuch) so they only have to do this once; if they come to this page but they've already had a cookie assigned (i.e. they've loged in before) you can send a "$query->redirect ()" to send them onward automatically.

Replies are listed 'Best First'.
Re: Re: Creating a login page
by mnlight (Scribe) on Dec 21, 2001 at 04:11 UTC
    So what does this error mean.

    Can't call method "header" on an undefined value at Password.pl line 22.

    1 #Volunteer.pl - Sign up sheet for Volunteers 2 3 use strict; 4 use DBI; 5 use CGI qw(:standard); 6 7 my ($dbh, $sth, $query); 8 my @player = (); 9 10 11 $dbh = DBI->connect ("DBI:mysql:host=localhost;database=<datab +ase>", 12 "mnlight","<paswword>", 13 {PrintError=> 0, RaiseError=> 1}); 14 15 $sth = $dbh->prepare ("select Player from Roster order by Play +er"); 16 $sth->execute (); 17 18 while (my @row = $sth->fetchrow_array ()) 19 { 20 push @player, $row[0]; 21 22 print $query->header(); 23 print $query->start_html(-title => 'Password');

    Edit kudra, 2001-12-22 Replaced br with code

      As japh said, you forgot the line:

      my $query = CGI::new;
      which generates a CGI object stored in $query. From then on, you can call methods (header() and such) on the object, while the object knows it's a CGI object (package CGI, and thus knows to find those methods in the CGI module.

      If you forget to initialize the object, you'd be trying to call methods on an undefined value, which doesn't belong to a package, simply because it's undefined.

      perhaps you meant:

      my $cgi = new CGI; print $cgi=>header(); print $cgi->start_html(-title=>'Password');
        I made the change and now I am getting the same error only on start_html instead of header

        Can't call method "start_html" on an undefined value at Password.pl line 26

        #Volunteer.pl - Sign up sheet for Volunteers use strict; use DBI; use CGI qw(:standard); my $query = new CGI; #my $query = CGI::new; my ($dbh, $sth, $query); my @player = (); $dbh = DBI->connect ("DBI:mysql:host=localhost;database=<database>", "mnlight","<password.", {PrintError=> 0, RaiseError=> 1}); $sth = $dbh->prepare ("select Player from Roster order by Player"); $sth->execute (); while (my @row = $sth->fetchrow_array ()) { push @player, $row[0]; print $query=>header(); print $query->start_html(-title=>'Password');. print $query->start_form('POST','/cgi-bin/Password.pl'), print $query->scrolling_list( -name =>'Player', -value =>[@player], -size =>'20'); } print "<p>"; print $query->password_field(-name => 'Password', -size => 8, -override => 1,); print end_form,