SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Using uniqid() - I'm a noob
-
Oct 10, 2009, 05:10 #1
- Join Date
- May 2008
- Location
- London, England
- Posts
- 135
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Using uniqid() - I'm a noob
The website I'm doing at the moment they want a URL generated with two unique numbers in it. Like this:
https://website.com/cl10/signup.php?...11&id2=8.1.1.1
Only everytime a user clicks on this the id1 and the id2 should be different. I think you can do it with PHP using uniqid() function. Does anyone know where I can find out how to do that.
Thanks
-
Oct 10, 2009, 09:23 #2
- Join Date
- Jul 2007
- Location
- San Jose, California
- Posts
- 355
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
srand(mktime());
$url = "http://www.website.com?id=".rand()."&id2=".rand();
-
Oct 10, 2009, 09:42 #3
- Join Date
- May 2008
- Location
- London, England
- Posts
- 135
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Hi baileylo,
I added this to the HTML to try to get the link:
HTML Code:<a href="<?php srand(mktime()); $url = "http://www.website.com?id=".rand()."&id2=".rand(); ?>" title="">
-
Oct 10, 2009, 10:40 #4
- Join Date
- Jul 2007
- Location
- San Jose, California
- Posts
- 355
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you're not printing anything
<?php
srand(mktime());
$url = ......what we already had ...;
?>
<a href="<?= $url ?>">URL</a>
That'll only work if you got short tags on
-
Oct 10, 2009, 11:09 #5
You gotta echo out the $url,
PHP Code:<a href="<?php srand(mktime()); echo $url = "http://www.website.com?id=".rand()."&id2=".rand(); ?>" title="">
-
Oct 12, 2009, 02:58 #6
- Join Date
- May 2008
- Location
- London, England
- Posts
- 135
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Thank you baileylo and JREAM. I'm using JREAM's code and it's working great. I've also started going through the tuts at W3schools to try to get some idea into my head about PHP.
Bookmarks