IT.COM

Need a random url script

Spaceship Spaceship
Watch
Impact
0
hope this isn't too off topic but does anyone know of a simple random url script? prefereably php or javascript
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Random URL script meaning?
 
0
•••
What specific "Random URL Script" is it? Got any sample sites? :)
 
0
•••
Would it be something like:
Submit URL
Select random from site

or

Generates random URL?
 
0
•••
0
•••
Submitted pages? or just goes to any page on the web?
 
0
•••
Submitted pages? or just goes to any page on the web?

i'll define the pages. i used to have a script that would go to a random page. had a text file where you could list the urls.
that was several computers ago and it's a goner now.
anyway, i'm looking for a script where i can list a bunch of urls and have it go to one of them. doesn't really have to be in php.
thanks
stevie
 
0
•••
Create theses 2 files:
file.php (or what ever you want to call it)
url.txt

Put this in the .php file:
PHP:
<?
$lines = file("url.txt") ; 
$url = $lines[array_rand($lines)] ; 
header("LOCATION: $url");
?>

then put the url's in the url.txt file (one URL per line)(make sure each URL has http:// or https://).
 
3
•••
Create theses 2 files:
file.php (or what ever you want to call it)
url.txt

Put this in the .php file:
PHP:
<?
$lines = file("url.txt") ; 
$url = $lines[array_rand($lines)] ; 
header("LOCATION: $url");
?>

then put the url's in the url.txt file (one URL per line)(make sure each URL has http:// or https://).


how many pages will randomize?
 
0
•••
You can add as many sites to url.txt you want.
It will only send you to 1 site though.
Unless you want it to send you to more.
 
1
•••
Its better to use a Database rather than a file because during concurrent read operations by different clients, your file may get struck or even corrupted.
Database is reliable for long term.
 
Last edited:
1
•••
0
•••
This is really cool I will give it a test
 
0
•••
0
•••
Your welcome.
Hope it works for you ;)
 
0
•••
0
•••
What should I make the url on the page to go to the random link?

---------- Post added at 08:39 AM ---------- Previous post was at 08:32 AM ----------

nvm figured it out
 
0
•••
1
•••
Janine, PERL is black magic! haha :)
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back