-
URL with random numbers/letters?
My question is this.... I have my table set up to have one column (id) to increment each time a new row is added. I want to be able to give the users the ability to tell other people about their stuff, so I could give them the link as such:
www.whateverlink.com/page.php?id=80
But, I'm wondering if there is a way to make the id number a little more unique? (don't know if that's the right word) For example: hot or not has this....
http://hotornot.com/r/?eid=RYK8ALA-LQA
I'd like to have something similar to RYK8ALA-LQA at the end of the url instead of 80... if that makes sense. (Also, i don't know if this is possible, but is there a way to not say the page name like the hotornot link did?)
How can I accomplish these two things? Any help would be appreciated!
Thanks!
-
-
I'd assume hotornot uses PHP. Try typing ..../index.php?eid=[value]
Just like with any site, the index page is the default. You don't need to type that. You just place the question mark and the value at the end, so /directory?var=value will be the same as /directory/index.php?var=value, or /dir/?var=value.
Generating a 'random' value is not that difficult, though it depends on what you want, really. You can't have it still relate to a numerical ID in the database, so you will need to store this new ID in the database instead.
Creating a hash from the md5() function will generate a 32-character value based on input, and it will always be the same. You could use md5(time().microtime()) and get a unique value easily.
If you wanted it shorter, that would be fine, just shorter it using substr(), but that would leave a greater chance that you would run into duplicates.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks