Home  |  Linux  | Mysql  | PHP  | XML
From:Greg Jetter Date:Mon Dec  7 17:43:32 2009
Subject:Re: Showing errors with user input
On Sunday 06 December 2009 10:24:31 am Adam Jimerson wrote:
> I am working on a registration page and there for want it to show the
> user errors it has found with their input. I have two subroutines in
> my code, the first one prints out the form, also takes an array with
> error descriptions that is passed by the other subroutine. The other
> subroutine takes the user input and verifies it, any errors that it
> finds it pushes into an array called @errors and passes that back to
> the first subroutine. The problem is it doesn't work right when I
> run it from the command line this is what I get:
>
> vendion@SEServer:~/public_html/AmeriVista> perl -cT register.cgi
> [Sun Dec 6 14:12:12 2009] register.cgi: Illegal character in
> prototype for main::form_verify : @user at register.cgi line 43.
> [Sun Dec 6 14:12:12 2009] register.cgi: Scalar found where operator
> expected at register.cgi line 93, near "$user"
> [Sun Dec 6 14:12:12 2009] register.cgi: (Missing semicolon on
> previous line?)
> [Sun Dec 6 14:12:12 2009] register.cgi: main::form_verify() called
> too early to check prototype at register.cgi line 36.
> Content-type: text/html
>
> <h1>Software error:</h1>
> <pre>syntax error at register.cgi line 93, near &quot;$user&quot;
> Global symbol &quot;$GoodMail&quot; requires explicit package name at
> register.cgi line 93.
> register.cgi had compilation errors.
> </pre>
> <p>
> For help, please send mail to this site's webmaster, giving this error
> message
> and the time and date of the error.
>
> </p>
> [Sun Dec 6 14:12:12 2009] register.cgi: syntax error at register.cgi
> line 93, near "$user"
> [Sun Dec 6 14:12:12 2009] register.cgi: Global symbol "$GoodMail"
> requires explicit package name at register.cgi line 93.
> [Sun Dec 6 14:12:12 2009] register.cgi: register.cgi had compilation
> errors.
>
> I have attached my code for the script, if someone could look at it
> and give some ideas as to how to make this work or a better way then
> please do

You are trying to use a local scoped var as a global , line 93 $GoodMail is
used out of its scope ,

if ( $user[5] =~ /^([-\@\w.]+)$/ ) {
$user[5] = $1;
eval {
my $GoodMail = Email::Valid->address( -address => "$user[5]", -mxcheck =>
1);
return;
}
#push @errors, "<p>Error: Double check your email address</p>" if $@;
$user[5] = $GoodMail;
}


it should read

if ( $user[5] =~ /^([-\@\w.]+)$/ ) {
my $GoodMail ;
$user[5] = $1;
eval {
$GoodMail = Email::Valid->address( -address => "$user[5]", -mxcheck => 1);
return;
}
#push @errors, "<p>Error: Double check your email address</p>" if $@;
$user[5] = $GoodMail;
}

or even declare it up with the other globals if you want , but the way you
have it now it is out of scope after that eval { } block completes.


there may be other errors , fix that one first and try it again and see what
else pops up.

have fun

Greg

Navigate in group perl.beginners.cgi at sever nntp.perl.org
Previous Next


Your recent visits
Re: how to add support of Msql and CGI in Apache
Re: CGI ap on NetworkSolutions host
Re: Are there any free web hosting providers who also allow perl scripting?
Re: Perl CGI advise/feedback please ...
SUMMARY: Problem uploading large files (broken storing)



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants