PDA

View Full Version : Click -> Go to this page randomly every 1/1000



M2JC
Apr 17th, 2017, 12:12 PM
What would the code look like for the above in HTML?

coothead
Apr 17th, 2017, 01:31 PM
Click -> Go to this page randomly every 1/1000
What would the code look like for the above in HTML?
Rather childish and amateurish.:D


coothead

M2JC
Apr 17th, 2017, 01:58 PM
Definitely amateurish. Is there a better way of thinking about how a button or link like this would work?

coothead
Apr 17th, 2017, 03:04 PM
Hi there M2JC,


sending a visitor to a random site needs to be done sever-side.

Do you have a site with PHP enabled?

If so here is a basic example...



<?php

$a=array(
'http://google.com/',
'http://yahoo.com/',
'http://bbc.co.uk/',
'http://www.codingforums.com/',
'https://startpage.com/'
);

$website = $a[mt_rand(0, count($a) - 1)];

?>

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>untitled document</title>

<link rel="stylesheet" href="screen.css" media="screen">

</head>
<body>

<a href="<?php echo $website; ?>">random website</a>

</body>
</html>



coothead

M2JC
Apr 17th, 2017, 09:38 PM
Hi coothead,

I see why you deemed this childish! Ha

I meant, how would I code a button to send people to one page on my own site 1/1000th of the time and 999/1000th of the time to a second page on my own site.

And preferably to the 1/1000th page only once every thousand clicks but randomly.

Thanks for your feedback so far.

Random page of the internet would be cruel and unusual haha