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:
Redirect script?

 



abar
Deleted

Feb 19, 2000, 11:05 AM

Post #1 of 4 (858 views)
Redirect script? Can't Post

I installed a survey script that works fine, however there is an option to send users to a redirected page rather than have them see the results:

# IF $SHOW_RESULTS=0 (do not display after voting), be sure
# to set $JUMP_URL to the page the voter should be sent to.

$SHOW_RESULTS=0;
$JUMP_URL="$ENV{'HTTP_REFERER'}";

The script only prints the address on the screen and does not redirect... here is the print portion:

}
else{
print "Location: $JUMP_URL\n\n";
}
exit;
}

How can I change this to a redirect??

The entire script is at: http://www.bignosebird.com/carchive/survey/survey.txt

Thanks!


Cure
User

Feb 19, 2000, 12:07 PM

Post #2 of 4 (859 views)
Re: Redirect script? [In reply to] Can't Post

Hi

Because you are printing a header(Content-type: text/html\n\n) before the redirection header(Location: $JUMP_URL\n\n)


Cure

[This message has been edited by Cure (edited 02-19-2000).]


abar
Deleted

Feb 19, 2000, 12:44 PM

Post #3 of 4 (858 views)
Re: Redirect script? [In reply to] Can't Post

Cutre, thanks for the quick reply.. how do I rectify the situation in order to make it redirect to a new page?

I do not need the headers or any of the stuff above the redirection to show up at all..

Thanks.


Cure
User

Feb 19, 2000, 1:55 PM

Post #4 of 4 (859 views)
Re: Redirect script? [In reply to] Can't Post

Hi

How ever made that script did a fairly poor job::

To make it redirect to another location instead of printing the results then comment out this LINE::-> print "Content-type: text/html\n\n";

Example::
(this is in your script-> you see how a put a # in front of print "Content-type: text/html\n\n"; the # symbol telling perl to ignore it.


$MODE="VOTE";
#print "Content-type: text/html\n\n";
&set_colors;
&process_file;
&do_stats;
if ($SHOW_RESULTS == 1){
$PAGEHEADER=&set_page_header;
$PAGEFOOTER=&set_page_footer;
print "$PAGEHEADER\n";
&display_stats;
print "$PAGEFOOTER\n";
}
else{
print "Location: $JUMP_URL\n\n";
}
exit;
}


Cure


 
 


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

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