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.

Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.