in reply to Re: cgi error output
in thread cgi error output

i tried that before bt never worked for me

here is the simple

$usr = $cgi->param('textfield);
$pwd = $cgi->param('textfield2);
if (! $usr) { # print error }
print <<HTML;
<html> <head> <body> <p><strong>Username <input type="text" name="textfield" /> </strong></p> <p> Password <input type="text" name="textfield2" /> </p> <p> <input type="submit" name="Submit" value="Submit" /> # LET THE ERROR BE SHOWN HERE </p> </body> </html> HTML;

Replies are listed 'Best First'.
Re^3: cgi error output
by hippo (Archbishop) on Apr 15, 2015 at 14:17 UTC
    my $error = $usr ? '' : 'Gah! No usr supplied!'; print <<HTML; <html> <head> <body> <p><strong>Username <input type="text" name="textfield" /> </strong></p> <p> Password <input type="text" name="textfield2" /> </p> <p> <input type="submit" name="Submit" value="Submit" /> <div class="error">$error</div> </p> </body> </html> HTML

    ... for example, but yes templates would probably be much better.

      i agree with ur simple, and i tried it already it works. bt the problem if ur doing it on login or sigin up page when u have set the cookie it prints the header at the top of the page

      second: when u exit with zero to terminate the process when its false, it works bt takes u to other blank page with the reponse, when there is no exit it works well bt it continue processing even if the process is false

Re^3: cgi error output
by Corion (Patriarch) on Apr 15, 2015 at 13:58 UTC

    What kind of error do you mean?

    Maybe you want to learn about how to output HTML in parts? Maybe a templating system is useful to separate the HTML you generate from your Perl code?

    Maybe you want to just

    if( $errorMessage ) { print $errorMessage; }

    ... in the right place?