Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Having trouble with redirect code
Old 07-25-2006, 08:34 PM Having trouble with redirect code
rel
Junior Talker

Posts: 1
Name: roger
Trades: 0
Hi everyone, I am fairly new to php and I am trying to get a redirect page to work and almost have it except I can not seem to include a variabled passed in via the incoming link to the new redirected link in the code. Here is what I have in a file called jump.php. I want to be able to pass in an url like http://mydomain.com/jump.php?id=1&ref=2 and have it redirect to http://linkout.com&ref=2

How do I properly insert the code after ref= to pass in the variable that came in via the incoming url?

PHP Code:
<?php
$id 
=$_GET['id'];
$ref =$_GET['ref'];
if (
$id == "")  {$link 'http://linkout.com&ref=';}  //Default Blank
if ($id == "1")  {$link 'http://linkout.com&ref=';} // page 1
header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header
header("Location: $link"); // Jump to the link
exit();
?>
rel is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-25-2006, 09:13 PM Re: Having trouble with redirect code
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
PHP Code:
$id = ( isset($_GET['id']) ) ? $_GET['id'] : false;
$ref = ( isset($_GET['ref']) ) ? $_GET['ref'] : false;
$link 'http://linkout.com?';
$q = ( $id && $ref ) ? '&' '';
if (
$id )  { $link .= "id=$id"; }  //Default Blank
if ($ref)  {$link .= "{$q}ref=$ref"; } // page 1
header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header
header("Location: $link"); // Jump to the link
exit(); 
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.

Last edited by metho; 07-26-2006 at 02:34 AM.. Reason: missing ? in url for $ref if $id not set
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Reply     « Reply to Having trouble with redirect code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09576 seconds with 12 queries