CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
New Error Question

 



etheracide
journeyman

Jul 27, 2001, 10:37 AM

Post #1 of 5 (637 views)
New Error Question Can't Post

Well I basically found my way out of the problem I had.
I figured out a way to send incorrect logins to an error HTML file..but I encountered something I would like to change:

click below if you do not know what my original post was:
original post

Here is how I currently have it written. I used the same thing I had written to redirect to a hidden page when the login info was correct:

sub error {
($error) = @_;

$JSCRIPT = "<SCRIPT LANGUAGE=\"JavaScript\"></SCRIPT>";
$cookie1 = $a->cookie(-name=>'user', -value=>$user, -expires=>'+1h');
$cookie2 = $a->cookie(-name=>'pass', -value=>$pass, -expires=>'+1h');
print $a->header(-cookie=>[$cookie1,$cookie2]);
print $a->start_html(-title=>'Redirect!', -bgcolor=>$bgcolor, -text=>$text, -link=>$link, -alink=>$alink, -vlink=>$vlink);
print "$banner
\n";
print "$JSCRIPT\n";
print "You are being redirected...
\n";
print $a->end_html;
}


I took out the part about the cookies since I do not need them for the error page. So I took out the lines with the cookies and I set the
print $a->header() to a null value. This generated errors.

I am sure that the answer is probably simple as to what the header should be set to, but it escapes me now.

Everything works fine with the way that I have it above, but the generated page shows you the cookies printed on the screen before you are taken to the actual error HTML page. I want the cookies for the login part obviously which is why I put them there Smile, but I cant get the error subroutine to work without that.


#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();


Jasmine
Administrator / Moderator

Jul 28, 2001, 9:10 AM

Post #2 of 5 (626 views)
Re: New Error Question [In reply to] Can't Post

Can you please post the code that doesn't work as well as the error message received? If you happen to be getting the infinitely useful "Internal Server Error", toss this at the top of your program (under the shebang line):


Code
use CGI::Carp qw/fatalsToBrowser/;

This will give you real syntax errors to your browser. You'll still get the ISE if it's a fatal compile-time error, though.



etheracide
journeyman

Jul 28, 2001, 11:22 AM

Post #3 of 5 (622 views)
Re: New Error Question [In reply to] Can't Post

Here is the script that does work:

sub error {
($error) = @_;

$JSCRIPT = "<SCRIPT LANGUAGE=\"JavaScript\"></SCRIPT>";
$cookie1 = $a->cookie(-name=>'user', -value=>$user, -expires=>'+1h');
$cookie2 = $a->cookie(-name=>'pass', -value=>$pass, -expires=>'+1h');
print $a->header(-cookie=>[$cookie1,$cookie2]);
print $a->start_html(-title=>'Redirect!', -bgcolor=>$bgcolor, -text=>$text, -link=>$link, -alink=>$alink, -vlink=>$vlink);
print "$banner
\n";
print "$JSCRIPT\n";
print "You are being redirected...
\n";
print $a->end_html;
}


It takes them to the error page, but the redirect page prints cookies which are visible for 5 seconds or so then redirects them to the error html file that i set as $errorurl. I have no need at all for cookies.

Here is what I tried that did not work


sub error {
($error) = @_;

$JSCRIPT = "<SCRIPT LANGUAGE=\"JavaScript\"></SCRIPT>";
print $a->header();
print $a->start_html(-title=>'Redirect!', -bgcolor=>$bgcolor, -text=>$text, -link=>$link, -alink=>$alink, -vlink=>$vlink);
print "$banner
\n";
print "$JSCRIPT\n";
print "You are being redirected...
\n";
print $a->end_html;
}


This did not work and when I checked my error logs, it told me that there were no recent errors. I put theCARP on my scripts, but if there is an error, hypermart's system kicks in and takes me to their error logs.

I took out the cookie lines because I do not need them for an incorrect login. And I removied the cookie part from the header and left the headaer value null.

If anyone has a better way of making the the script bring up $errorurl than the redirect way I have, i would LOVE to hear it. I had written the redirect part because it is necessary for overal script. But it was the only way that popped into my head to bring up $errorurl. I will gladly listen to any ways to remove the cookie lines from the redirect method...or a whole new method altogether. There is a reason that I post in the beginner section =0)

Thank you.



#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();


Jasmine
Administrator / Moderator

Jul 28, 2001, 1:27 PM

Post #4 of 5 (619 views)
Re: New Error Question [In reply to] Can't Post

Forgive me for being dense, but I don't see how either pieces of code work. Neither show a redirect url or javascript code that would actually perform the redirection.

However, I use this for redirections:

Using CGI.pm:

Code
print $in->redirect( $url );

and not using CGI.pm:

Code
print "Location: $url\n\n";



etheracide
journeyman

Jul 28, 2001, 1:53 PM

Post #5 of 5 (615 views)
Re: New Error Question [In reply to] Can't Post

I am sorry, I have no idea what happened to the code. The code posted on there doesn't have the redirect part in the JavaScript. I should have checked it over befor ei posted it, but I copy and pasted from my source code so it should have been there.

Well I tried submitting the whole code again with the JavaScript and i am now on the second part where i can edit the post. And it changed the JavaScript AGAIN so I am going to not include it. But the javascript was a simple redirect code which called upon a scalar which i set equal to the URL of my error page and it worked fine but added the cookies.

But I am going to go ahead and try the CGI.pm code you suggested. Thank you for your help.

#!/usr/dusnt/know/perl

use CGI;
$a = new pointless CGI();

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives