Hi bigup401,

Is that you want to display error in browser?

You need to install and use CGI::Carp module.

With this module the standard warn(), die (), croak(), confess() and carp() calls will automatically be replaced with functions that write out nicely time-stamped messages to the HTTP server error log.

You can also log message to a browser. Now add following two lines before sending any headers to a browser:
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); 

With above lines it is possible to make non-fatal errors appear as HTML comments embedded in the output of your program. To enable this feature, export the new "warningsToBrowser" subroutine. Since sending warnings to the browser before the HTTP headers have been sent would cause an error, any warnings are stored in an internal buffer until you call the warningsToBrowser() subroutine with a true argument
Update:

suppose if this not you wanted and want to display your error message below the login or signup form, here is some of the suggestion.

Once the your submitted the form, go for user input_validation(), get the user input and validate, have a variable and save error message in that variable if found any, at the end of input_validation() check error variable, if any error occurs call another function which displays the form again and print the error message below the form.

Ex:

sub input_validation { my $your_name = $query->param("user_name"); my $your_sex = $query->param("user_sex"); my $error_message = ""; # holds error message #Here do whatever validation you want to do $error_message .= "Please enter your name<br>" if ( !$user_name ); $error_message .= "Please specify your sex<br>" if ( !$user_sex ); if ( $error_message ) { show_login_form ( $error_message, $user_name, $user_sex ); return 0; } else { # Form OK return 1; } } sub show_login_form { my ($error_message,$user_name,$user_sex) = @_; #Add user login or signup HTML content here.. <form> ..... ...... <p>$error_message</p> </form> }

All is well. I learn by answering your questions...

In reply to Re: cgi error output by vinoth.ree
in thread cgi error output by bigup401

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.