PHP and Javascript

Asked by:
ashraj98
Time:
2013-01-07 10:59 pm
Category:
Website Troubleshooting
Hits:
115
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?

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

arnelc
2013-01-07 11:29 pm
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.

You must login before you can post a comment about this answer.

Like this Question?

Have a Question?

If you need some help, submit your question to our Community! We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)

Recent Questions

  1. my email is being rejected
  2. Can I run the FiverrScript on my hosting
  3. SQL database password

Support 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.