Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Send this topic | Print
Topic: PHP Redirects  (Read 1153 times)
« on: November 09, 2007, 12:09:03 PM »
joshr35 Offline
Newbie

View Profile
*
Posts: 32



Hello,

Can anyone tell me how to create a php file that contains all of the redirects.
I already know how to create a php for just one redirect but I have several.

Thanks,

JR
Report to moderator   Logged

 
« Reply #1 on: November 09, 2007, 12:39:12 PM »
joshr35 Offline
Newbie

View Profile
*
Posts: 32



Ok,
I have the php script for several links:

<?
$linkid = $_GET['linkid'];
if ($linkid == "") {$link = "http://www.yoursite.com";}
header("Location: $link");
exit();
?>

And here's the new ref code:

<a href="http://www.yoursite.com/redirect.php?linkid=1" mce_href="http://www.yoursite.com/redirect.php?linkid=1">Affiliate Future Merchant Name</a>


What I dont understand is how to link the button on the page to the redirect php file.
Its easy if the php has only one code then the whole php is dedicated to only one redirect.

The only way I know how to link is to right click then select "hyperlink"  But thats only letting me select the whole php page. 
Does anyone know the code for linking to the internal php script that I need?
Report to moderator   Logged
« Reply #2 on: November 09, 2007, 03:19:54 PM »
JOE24
Dollar Offline
Jr. Member

View Profile
**
Posts: 99



hmm I look into this,
btw you should put the code in code tags. You giving Live links to a site called
yoursite.com  (which is a real website) lol
Report to moderator   Logged

« Reply #3 on: November 09, 2007, 03:49:48 PM »
joshr35 Offline
Newbie

View Profile
*
Posts: 32



Sorry, the code I pasted in there is an un altered example of how to redirect, I just havent changed it yet.
Report to moderator   Logged
« Reply #4 on: November 09, 2007, 07:46:19 PM »
joshr35 Offline
Newbie

View Profile
*
Posts: 32



Ok, it still doesn't work but here is what I have done so far.

This is the php file:

<?
$linkid = $_GET['linkid'];
if ($linkid == "") {$link = "http://www.topsoftwaredownloads.t35.com";}
if ($linkid == 1") {$link = "http://sitet35.antispywre.hop.clickbank.net?aid=615&tid=-1&mode=download&pp=3";}
header("Location: $link");
exit();
?>


And this is what I have in the html body:

<a href="http:/www.topsoftwaredownloads.t35.com/redirect.php?linkid=1">


When I click on it I get the 404 file not found page.
Report to moderator   Logged
« Reply #5 on: November 09, 2007, 08:11:48 PM »
chickenmeister Offline
master of chickens
Global Moderator
Member

View Profile WWW
*****
Posts: 206



Ok, it still doesn't work but here is what I have done so far.

This is the php file:

<?
$linkid = $_GET['linkid'];
if ($linkid == "") {$link = "http://www.topsoftwaredownloads.t35.com";}
if ($linkid == 1") {$link = "http://sitet35.antispywre.hop.clickbank.net?aid=615&tid=-1&mode=download&pp=3";}
header("Location: $link");
exit();
?>

You have a syntax error (highlighted in red above). This should fix it:

Code:
<?php
$linkid 
$_GET['linkid'];
if (
$linkid == "") {$link "http://www.topsoftwaredownloads.t35.com";}
if (
$linkid == 1) {$link "http://sitet35.antispywre.hop.clickbank.net?aid=615&tid=-1&mode=download&pp=3";}
header("Location: $link");
exit();
?>
Report to moderator   Logged

Hello world!
« Reply #6 on: November 09, 2007, 08:31:05 PM »
chickenmeister Offline
master of chickens
Global Moderator
Member

View Profile WWW
*****
Posts: 206



Also, if you're planning on having huge if/elseif test sequence, might I suggest a better way...

first off you would simply put all the urls that you want to redirect to in a text file. For example

links.txt
Code:
http://website1.com
http://website2.com
http://website3.com
http://website4.com
http://website5.com
etc...

and in your redirect.php file, put this:

Code:
<?php
$urlArray 
file("links.txt"); //read the lines of the text file into an array
$linkid $_GET['linkid'];  //get the link id

//check to make sure that the link id is within the bounds of the array
//if it isn't, redirect to some backup url
if ( ($linkid 0) || ($linkid > (sizeof($urlArray)-1)) )
{
    
//this will redirect to http://yoursite.com
    
$urlArray[0] = "http://yoursite.com";
    
$linkid 0;
}

//fetch the URL in the array at the linkid position
Header("Location: " $urlArray[$linkid] );
?>

and http://yoursite.com/redirect.php?linkid=0 will redirect to http://website1.com,
http://yoursite.com/redirect.php?linkid=1 redirects to http://website2.com,
and so on.
« Last Edit: November 09, 2007, 08:34:11 PM by chickenmeister » Report to moderator   Logged

Hello world!
« Reply #7 on: December 07, 2007, 10:27:08 PM »
Michael D Price Offline
Newbie

View Profile
*
Posts: 3



 Here is a piece of code i just wrote for my own use, however this could be helpful for any of you with php scripts.

DO you run a membership site, or even operate a squeeze page?

Make The Most Out Of Your Opt-In And Activation Pages.

You are generating traffic to these pages, why not make good use of them.

This code will allow a timed redirect during your confirmation or activation pages.

On your thank you page for confirming their email address or on the optin check confirmation pages, you can have a timed redirect on php pages.

Now how you put that to use is to have a processing header.
ie ... Please wait while we add you to our list.
Set this to 15 seconds, and while they are waiting post some type of advertisment. Whether you want them to click on a link or just to inform them.

make ads open in new mindows.
After 15 seconds pass they are redirected to a new page.

Here is the code.
Put this in your php templates head section.

Code:
<?php 
if($timed_redirect==1){
echo 
"<meta http-equiv=\"refresh\" content=\"$time;URL=$url\">";
?>



Then set this and put it in your php page that process the ... whatever

Code:
$timed_redirect=1;
$url='index.php';
$time='30';
« Last Edit: December 07, 2007, 10:29:02 PM by Michael D Price » Report to moderator   Logged
« Reply #8 on: January 27, 2008, 03:16:46 PM »
weedgrinch Offline
Newbie

View Profile
*
Posts: 10



You can use headers, or even Curl.  If you wanted to, you could use javascript, and meta tags (meta tags are html).
Report to moderator   Logged
 
Pages: [1]
Send this topic | Print
Jump to:  

Powered by SMF | SMF © 2006-2008, Simple Machines LLC