Hello all,
Is there any way to have a script load on a web page and if in the script a condition is met to have it abort the page load and redirect to another page?
The whole idea is I dont want to call the script from a link. That would be easy but the user could just type in the page and go there directly.
This isn't meant to stop someone who really wants to see the page, just a normal user navigating via the links or typed in in the address bar directly.
I want to have it so that if a condition is met they will NOT view the page they were loading and only view the page they are being redirected to.
I know this is a silly little excersise but since I couldn't get it to work the way I want it has me curious.
Calling the script isn't my problem...well maybe the WAY I'm calling it is but the script does run and check the condition. What is failing is the redirect.
using the exec SSI call is not an option so i call the script with a <script src="script.pl"></script> tag in the head of the html document.
Everything works fine up until this point in the script:
if(condition)
{
print "Content-type: text/html\n\n";
print "Location: $REDIRECT\n";
}
All that happens is the page that was being loaded is displayed. I know that the code inside the if statment IS being executed with a proper URL.
It's just not doing what I want.
Any ideas?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.