Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 30th Apr 2011, 01:27 AM   #1
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
[HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Hi

I want to send visitors to 5 different squeeze pages using some kind of php redirect.

This means that when Visitor A come via URL, automatically he will be redirected to URL1 and the next visitor will be re-directed to URL1.

So, Visitors Click on the link and sequentially each will be directed to different squeeze pages.

Let say I have 5 visitors who click through the link, so:

visitor 1 -> URL1,
visitor 2 -> URL2,
visitor 3 -> URL3,
visitor 4 -> URL4,
visitor 5 -> URL5,
visitor 6 -> URL1,

and so on....

Can someone teach me how to do this using PHP re-direct? Thanks...
Raiser is offline  
Unread 30th Apr 2011, 02:33 AM   #2
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Ok this should work

<?php

$links = array("URL1", "URL2", "URL3", "URL4", "URL5");

$hits = @file_get_contents("hits.txt");

$fh = fopen("hits.txt", "w");

if($hits >= count($links))
{
$hits = 0;
fputs($fh, $hits);
}
else
{
$newhit = $hits + 1;
fputs($fh, $newhit);
}

fclose($fh);

header("Location: ".$links[$hits]);

?>

kaido is offline  
Unread 30th Apr 2011, 02:37 AM   #3
Active Warrior
 
Join Date: 2011
Posts: 37
Thanks: 10
Thanked 3 Times in 3 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

if you want redirect to different page
<?php
header("Location:your address here");
?>
you can do this random with PHP RAND (google it)
do something like this
PHP Code:
<?php
=rand(1,5);
if(==
1){
=
"your address";
}
if(==
2){
=
"another address";
}
//you need to continue ...
echo "<a href="">click here</a>";
?>
good luck!!!
omerbsh is offline  
Unread 30th Apr 2011, 09:18 AM   #4
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by kaido View Post

Ok this should work

<?php

= array("URL1", "URL2", "URL3", "URL4", "URL5");

= @file_get_contents("hits.txt");

= fopen("hits.txt", "w");

if( >= count())
{
= 0;
fputs(, );
}
else
{
= + 1;
fputs(, );
}

fclose();

header("Location: ".);

?>
When I did the above, re-direction did not take place, and the browser showed:

= count($links)) { $hits = 0; fputs($fh, $hits); } else { $newhit = $hits + 1; fputs($fh, $newhit); } fclose($fh); header("Location: ".$links[$hits]); ?>

Not sure why it didn't work. :confused:

My questions:

Do I have to create a dummy file hit.txt and upload to same directory?
Am I suppose to replace the URL1, URL2, URL3, URL4, URL5 with where I want to redirect to and keep everything else intact?

Thanks to advise.
Raiser is offline  
Unread 30th Apr 2011, 09:27 AM   #5
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by omerbsh View Post

if you want redirect to different page
<?php
header("Location:your address here");
?>
you can do this random with PHP RAND (google it)
do something like this
PHP Code:
<?php
=rand(1,5);
if(==
1){
=
"your address";
}
if(==
2){
=
"another address";
}
//you need to continue ...
echo "<a href="">click here</a>";
?>
good luck!!!
Sorry, I'm a little slow. Don't really understand what you mean. Am not a techie at all.. :p Can you make it idiot proof, please?
Raiser is offline  
Unread 30th Apr 2011, 09:28 AM   #6
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Heh there seems to be problems with warrior forum php insertion compare this code with my edited post and youll see difference. Grab edited code from my first post and it should work.

hits.txt will be generated automatically
and yes replace UR1, URL2 and so on with your desired links. You can add them as much as you wish

kaido is offline  
Unread 30th Apr 2011, 10:06 AM   #7
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by kaido View Post

Heh there seems to be problems with warrior forum php insertion compare this code with my edited post and youll see difference. Grab edited code from my first post and it should work.

hits.txt will be generated automatically
and yes replace UR1, URL2 and so on with your desired links. You can add them as much as you wish
@kaido

Thanks for reply. Still having the same problem. :confused:

No redirection happen. Only the following is displayed in the browser:

= count($links)) { $hits = 0; fputs($fh, $hits); } else { $newhit = $hits + 1; fputs($fh, $newhit); } fclose($fh); header("Location: ".$links[$hits]); ?>
Raiser is offline  
Unread 30th Apr 2011, 10:13 AM   #8
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Ok attached it as file try this just tested works perfectly
Sorry cannot attach it as file so i uploaded it to rapidshare
https://rapidshare.com/files/459952282/redir.zip

kaido is offline  
The Following User Says Thank You to kaido For This Useful Post:
Unread 30th Apr 2011, 10:17 AM   #9
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by kaido View Post

Ok attached it as file try this just tested works perfectly
@Kaido, you do mean to copy the code in your first post, change the URL to the one i want to direct. Next save as file with .html and upload to root directory.

With this, when I type in browser http://www.mydomain.com/redirect.html, it should work?

Appreciate your patient. I really not good with all these coding stuff. But I need this to split test my squeeze page.
Raiser is offline  
Unread 30th Apr 2011, 10:20 AM   #10
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Its php file so if you will rename it to "redirect"
then you should access it as http://www.mydomain.com/redirect.php

kaido is offline  
The Following User Says Thank You to kaido For This Useful Post:
Unread 30th Apr 2011, 10:27 AM   #11
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by kaido View Post

Its php file so if you will rename it to "redirect"
then you should access it as http://www.mydomain.com/redirect.php
@Kaido,

Oops! :p Sorry. I'm dumb. Let me try it with the file you have provide. I really appreciate your kind help. Have been trying to solve this for 4 days now
Raiser is offline  
Unread 30th Apr 2011, 10:37 AM   #12
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

@Kaido!

Yes it works!! But I encountered another problem.

When i hit refresh, it cycled through the different squeeze pages expect that when it went back to the first, it was showed 2 times. Here's what I mean:

Squeeze Page 1
Squeeze Page 2
Squeeze Page 3
Squeeze Page 4
Squeeze Page 5
Squeeze Page 1
Squeeze Page 1

Squeeze Page 2
Squeeze Page 3 and so on. Notice when it went back to 1st page, it was refreshed 2 times.


Do you know how to build a counter in the process so that I know each page is directed to how many times?

Also, how do I reset the process so that it starts from the first squeeze page when I launch it? Can you educate me on this, pls?
Raiser is offline  
Unread 30th Apr 2011, 11:36 AM   #13
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Ok here's an basic one with counter.
It will create an text file for every link. Named as link0.txt, link1.txt and so on
Number in those files shows you how many times your specific lik has redirected. File names are in that order in which you'll put your links into array.

Also that double redir is fixed now
You can reset it to start from the beginning by editing file hits.txt by setting it contents to number 0

https://rapidshare.com/files/459963058/redir.zip

kaido is offline  
The Following User Says Thank You to kaido For This Useful Post:
Unread 30th Apr 2011, 11:39 AM   #14
ResponseQue
 
zvendor's Avatar
 
Join Date: 2011
Posts: 25
Thanks: 0
Thanked 2 Times in 2 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Are you trying to do a split test? If so why don't you just use Google Website Optimizer to do your split testing for you? It's easier and it works better with Google Analytics.

=================================================
Automate your online customer service... www.ResponseQue.com
Save Time, Save Frustration, Provide Customer Satisfaction! P.S. Check out our awesome affiliate program!
=================================================
zvendor is offline  
The Following User Says Thank You to zvendor For This Useful Post:
Unread 30th Apr 2011, 01:37 PM   #15
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Ok i made an script for you for easier managment.
https://rapidshare.com/files/459979661/redir.zip

Basically you can add and remove websites from it by logging in from admin/index.php
username as "user" and password is "pass" you can change them from conf/config.php
also it displays how many hits specific link has got.

Happy redirecting

kaido is offline  
The Following User Says Thank You to kaido For This Useful Post:
Unread 30th Apr 2011, 08:20 PM   #16
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

Originally Posted by kaido View Post

Ok i made an script for you for easier managment.
https://rapidshare.com/files/459979661/redir.zip

Basically you can add and remove websites from it by logging in from admin/index.php
username as "user" and password is "pass" you can change them from conf/config.php
also it displays how many hits specific link has got.

Happy redirecting
AWESOME! Thanks Kaido. You are SUCH a great help - honestly. Let me try out the new solution and give you some feedback. I'm really lost without a solution. If I can put another few thanks under your belt, I would. For now let me get you a drink of your choice => cU

Originally Posted by zvendor

Are you trying to do a split test? If so why don't you just use Google Website Optimizer to do your split testing for you? It's easier and it works better with Google Analytics.
Yes, I'm trying to split test the opt in pages. The original plan was to use Google Website Optimizer, and I tried getting it to work. However, for some reason, I can't get the scripts into the <head></head>. Tried several plugins including HiFi and GWO4WP. None work. It could be the theme I'm using. I'm on multi stream theme. Would be glad if you can teach me how to make it work... :p
Raiser is offline  
Unread 1st May 2011, 03:11 AM   #17
Warrior Member
 
Join Date: 2009
Posts: 28
Thanks: 11
Thanked 0 Times in 0 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

YES! It's working fine now Kaido! Thanks a million for your kind help!
Raiser is offline  
Unread 1st May 2011, 04:21 AM   #18
Active Warrior
War Room Member
 
kaido's Avatar
 
Join Date: 2009
Posts: 48
Thanks: 1
Thanked 7 Times in 7 Posts
Default
Re: [HELP] PHP scripts for redirecting purpose
Share on: 
fb share twitter share gplus share more share

No problem

kaido is offline  
Closed Thread


Bookmarks

Tags
php, purpose, redirecting, scripts


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




All times are GMT -6. The time now is 02:27 AM.