Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-28-2007, 02:05 PM   #1
ztik
Confirmed User
 
ztik's Avatar
 
Industry Role:
Join Date: Aug 2001
Location: Nomad
Posts: 5,196
php help

so I am trying make a script that will goto 1 url or the other randomly

I figured I would make it select a random number then if $num = 1 goto www.google.com and if $num = 2 then goto www.yahoo.com

I can't seam to get it to work I can however get the number part to work


<?php

$num = mt_rand(1, 2);
echo($num);



?>



how would I go about finishing that?
__________________
.
ztik is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 02:19 PM   #2
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
PHP Code:
<?php

ob_start
();

list(
$num$url) = array(mt_rand(01), array('http://www.yahoo.com/''http://www.google.com/'));

header("Location: $url[$num]"); ob_flush(); exit();

?>
Use the url array to store the address you want to redirect to. The first parameter of mt_rand() must be zero, because the first index of an array is always 0 then, 1, 2, 3, etc. You'll want the second parameter to be total number items in the array. Don't forget the first item in the array is indexed as 0.
__________________
subarus.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 02:28 PM   #3
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
Levi can you msg me i been trying to reach you for over a week
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 02:32 PM   #4
fluffygrrl
So Fucking Banned
 
Join Date: May 2006
Posts: 2,187
What he said. Not sure you actually need the ob_start, you could echo a javascript redirect, depending what works for you.
fluffygrrl is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 02:38 PM   #5
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
@Fris, yeah I got your support ticket this morning. Haven't been on AIM much and had to disconnect my phone lines. College semester started 2 weeks ago been keeping me busy that's all..

@fluffygrrl, You don't in that example, but it's still good practice.
__________________
subarus.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 02:41 PM   #6
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,372
can you please hit me up when you can? thanks
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2007, 03:08 PM   #7
BIGTYMER
Junior Achiever
 
BIGTYMER's Avatar
 
Industry Role:
Join Date: Nov 2004
Location: Walled Garden
Posts: 17,066
PHP Code:
<?php
$url1 
'http://www.google.com';
$url3 'http://www.yahoo.com';
$lnk = array(); 
$lnk[count($lnk)] = $url1;
$lnk[count($lnk)] = $url2;
$count count($lnk); $i date(s); $i $i%$count; if($lnk[$i]){ $url $lnk[$i]; } else { $url $url1; }
header"Location: "$url );
?>
I'm not 100% sure what you need. That is one way to do it.
BIGTYMER is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.