Results 1 to 2 of 2

Thread: URL with random numbers/letters?

  1. #1
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •