in reply to Re: Error Message
in thread Error Message

Here I placed the "ind.cgi" coding and my home page "index.html" calling this cgi when user click the submit button.

#!C:\perl\bin\perl use strict; use CGI qw/:standard/; use DBI; my $q = new CGI; my $dbh = DBI->connect("DBI:mysql:project", {PrintError =>0, RaiseErro +r =>0}) ; my $us=$q->param('user'); my $pas=$q->param('pass'); my $sth = $dbh->prepare("SELECT * FROM user WHERE uname=? AND pass=PAS +SWORD(?)"); $sth->execute($us,$pas); my ($valid_user, $pp) = $sth->fetchrow_array(); if ($valid_user eq '') { print redirect('http://localhost/index.html'); } print $q->header("text/html"), $q->start_html(-title=>uc($q->param('REG')), -Background=>'EiffelTower +.tif'); print "<br><br><H1 align='center'><b><font face='Euclid fraktur' color +='cyan'>P</font><font face='Euclid fraktur' color='megantha'>E</font> +<font face='Euclid fraktur' color='yellow'>R</font><font face='Euclid + fraktur' color='pink'>L</font> <font face='Euclid fraktur' color='Re +d'>M</font><font face='Euclid fraktur' color='Green'>O</font><font fa +ce='Euclid fraktur' color='blue'>D</font><font face='Euclid fraktur' +color='cyan'>U</font><font face='Euclid fraktur' color='megantha'>L</ +font><font face='Euclid fraktur' color='yellow'>E</font><font face='E +uclid fraktur' color='orange'>S</font></H1>"; $dbh->disconnect; print $q->end_html;

Replies are listed 'Best First'.
Re^3: Error Message
by davidrw (Prior) on Jul 04, 2005 at 19:12 UTC
    couldn't resist rewriting that huge print statement :)
    my @colors = qw/ cyan megantha yellow pink Red Green blue cyan meganth +a yellow orange /; my $font = 'Euclid fraktur'; print "<br><br><H1 align='center'><b>"; foreach my $letter ( split //, 'PERL MODULES' ){ do { print $letter; next; } if $letter = ' '; # special case of s +pace printf "<font face='%s' color='%s'>%s</font>", $font, $colors[0], $l +etter; push @colors, shift @colors; # rotate the colors } print "</b></H1>";

    As for your primary issue, I would suggest that index.cgi contain the login form (instead of a static index.html) so that you can dynamically add a message to it. Some pseudo code:
    $message = ''; if( $login_form_submitted ){ check user and pass params if ok redirect to main page else $message = 'login failed' end } print login form here, including $message if it is set

      Thank you very much for your help.

      Regards,
      Velusamy R