0

I'm trying to pass variables to a simple PHP script and have it redirect to different URLs depending on the values in the query string.

Here's what I have in bonus.php:

<?php

if ($_GET['pid'] == '3') {
    $bonus = "copy-paste-traffic";
}
elseif ($_GET['pid'] == '5') {
    $bonus = "lazy-affiliate-riches";
}

$redirect = "http://affiliatesilverbullet.com/.'$bonus'.-bonus/?mid=.'$_GET['mid']'.&pid=.'$_GET['pid']'.";

echo $redirect;

page_redirect($redirect);

?>

I want queries to redirect as follows:

asbfree.com/bonus.php?mid=dstruckman&pid=3 -> affiliatesilverbullet.com/copy-paste-traffic-bonus/?mid=dstruckman&pid=3

asbfree.com/bonus.php?mid=dstruckman&pid=5 -> affiliatesilverbullet.com/lazy-affiliate-riches-bonus/?mid=dstruckman&pid=3

But it's not working.

What am I doing wrong?

Please show me how to fix my bonus.php script to make this work.

Thanks in advance!

Dustin

2
  • "not working" is not an explanation. Commented May 10, 2011 at 2:39
  • Post the code for "page_redirect()" Commented May 10, 2011 at 3:20

3 Answers 3

1

I think you may change

$redirect = "http://affiliatesilverbullet.com/.'$bonus'.-bonus/?mid=.'$_GET['mid']'.&pid=.'$_GET['pid']'.";

to

$redirect = "http://affiliatesilverbullet.com/".$bonus."-bonus/?mid=".$_GET['mid']."&pid=".$_GET['pid'];

EDIT : ...change elseif to else if, page_redirect to http_redirect, and remove echo or place after redirect function.

Sign up to request clarification or add additional context in comments.

1 Comment

this also did not fix the issue.
0

I would use header("Location: $redirect"); instead of page_redirect($redirect);.

2 Comments

I think you mean header("Location: $redirect");
Whoops! Thanks Jason for calling out the typo!
0

One of the issues may be your variable interpolation. Replace

$redirect = "http://affiliatesilverbullet.com/.'$bonus'.-bonus/?mid=.'$_GET['mid']'.&pid=.'$_GET['pid']'.";

with

$redirect = "http://affiliatesilverbullet.com/{$bonus}-bonus/?mid={$_GET['mid']}&pid={$_GET['pid']}";

Next time you post a question it would be helpful to post the error message you are receiving.

2 Comments

I updated and it's still not working for me. The error I get is: Server error The website encountered an error while retrieving asbfree.com/bonus.php?mid=dstruckman&pid=3. It may be down for maintenance or configured incorrectly. Which you can see if you go to the URL.
Right, its throwing a 500 error and logging the error message somewhere. I'd check the apache error log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.