SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: hidden my id

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Question hidden my id

    i just finished my website my design as below
    database
    tblmenu
    -menu_id (primary key)
    -menu_name
    tblsubmenu
    -menu_id (foreign key)
    -sub_menu_id (primary key)
    -sub_menu_name
    when i click the menu it display my menu_id
    http://localhost/index.php?menu_id=1
    how to hide this id i try to used uniqid() but it have problem with my sub menu because it call an id from menu then compare in database any good solution for this? i wan to use md5 or uniqid to hide it
    thanks,

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Why? I mean, you CAN do it, but... why? Whats the difference between id=1 and id=129038823129387abbcff
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    Most people go the other way and use a user friendly slug:

    tbl_pages
    --------
    page_id
    slug //used to search for pages and pull it up

    http://localhost/index.php?menu_id=1 then becomes http://localhost/index.php?slug=my_page_slug, and then further you can use mod rewrite to change this to http://localhost/my_page_slug

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    Most people go the other way and use a user friendly slug:

    tbl_pages
    --------
    page_id
    slug //used to search for pages and pull it up

    http://localhost/index.php?menu_id=1 then becomes http://localhost/index.php?slug=my_page_slug, and then further you can use mod rewrite to change this to http://localhost/my_page_slug
    Or for simpler terms you could go from http://localhost/my_menu_name/1 to http://localhost/index.php?menu_id=1 so that you don't have to alter your code to convert your menu name to its id, you can simply read the id from the URL still.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i think because of my function compare
    SELECT * FROM tblmenu WHERE menu_id = 129038823129387abbcff
    that why it not work if i substr($strid,0,1) but when the number reach about 10,100,1000 how i gonna do?

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    49
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Dear K.Wolfe, cpradio
    yes i did here my rewrite url
    RewriteEngine On
    RewriteRule ^index.php$ index.php?menu_id=$1 [QSA]
    #RewriteRule ^([a-z]+)$ menu.php?ph_sc_menu_id=$1
    it not working also and i already test
    RewriteRule index.htm index.php [L] #it point to index.php it mean my mod_rewrite work
    now i have no choice because my domain and hosting waiting for me that's why i almost crazy

    regards,
    heng

  7. #7
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    This is just wrong:

    Quote Originally Posted by hengwebdeveloper View Post
    i think because of my function compare
    SELECT * FROM tblmenu WHERE menu_id = 129038823129387abbcff
    that why it not work if i substr($strid,0,1) but when the number reach about 10,100,1000 how i gonna do?

    If you want your display url to be long, then you need to make your ID in the table that long ID, dont run some sort of substr() or anything similar.


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
  •