Jump to content

random URL id upon refresh


allex01

Recommended Posts

I don't think you understood the question. pickled is correct, i don't think we could change that in URL, but i was asking if there was a way to do so.

 

I have this code

<?php

$w=rand();

?>

<a href="test.php?ran=<?php echo $w; ?>">test</a>

 

When you click on the test link, a page will be generated like test.php?ran=321234

 

Now if a user refreshes this page by pressing f5, i want the ran= to change automatically to another random number in the url without having to click on the test link again. I was asking if this can be done somehow.

Why would you need to do that? Why don't you just do a

$ran = rand();

in your page? I don't see a reason to use it from the url, if it's gonna be generated randomly all the time anyway? Then every time you refresh the page, $ran will be different..

 

 

edit:

 

If you need to set ran in the url to determine if something has been done, you can do something like this:

test.php?ran

if (isset($_GET['ran'])) {
$ran = rand();
}

  • 2 months later...

It's still possible.  What would be required is the use of a header command.  You'd probably have to set a cookie so that the system knew that this was not the first time the page was visited.  Don't know what the application of this idea is good for, since you haven't provided any detail.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.