PHP and Javascript

Asked by:
ashraj98 / 15 Points
Time:
2013-01-08 2:59 am EST
Category:
Website Troubleshooting
Hits:
411
I tried to run a script that redirects the user based on referrer url in PHP and Javascript, and neither work. Here is my code:

url = "*****URL*****";
if (document.referrer = url) { }
else {window.location = "*****OTHERURL*****"}

PHP:

$referrer = $_SERVER['HTTP_REFERER'];
$referrer = strtolower($referrer);
$referrer = explode ("/", $referrer);
$referrer = $referrer[2];

$targetref = "*****URL*****";
if ($referrer = $targetref) {
} else {
header( 'Location: *****OTHERURL*****' ) ;
}


I debugged it and i am sure it's right. Do i have to enable something in cpanel?

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

arnelc
Staff
17,314 Points
2013-01-08 3:29 am EST
Hello Ashraj98,

Your code for both requires some correction. Try reviewing the following links for this issue:


htaccess redirect

PHP

Javascript

If you're still having problems, please respond back with links to your code so that we can review the problem more in depth.

If you have any further questions, please contact technical support or leave a comment at the bottom of the page.

Regards,

Arnel C.

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}