How to make encrypted url working

Discussion in 'PHP' started by ketting00, Aug 19, 2014.

  1. #1
    I want to make a url look like this in the status bar:
    mysite.com/cGF0aD1ob21lJmZpbGU9ZGlzY292ZXIucGhw
    Code (markup):
    How do I do this.

    I pull user data from a database and use the get method to pass that data to another page. It's too explicit to show that data in the status bar and the next page's url. How do I obscure it while make the link working.

    Thank you,
     
    ketting00, Aug 19, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Why don't you just pull a user id or something, and pull the data on the new page? Or use post instead of get?
     
    PoPSiCLe, Aug 19, 2014 IP
  3. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #3
    Thanks,
    I get the picture. I just think about the possibility of this thing.

    The reason I want to use the GET instead of POST by using <a> tag in the <form> is the design would get ugly with hidden form and the GET method would keep me working in the current root directory.
     
    Last edited: Aug 19, 2014
    ketting00, Aug 19, 2014 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Yeah, don't ever pass explicit data via GET, encrypted or unencrypted. And especially not without SSL. Do as @PoPSiCLe says, and pass over IDs. Or used sessions.
     
    nico_swd, Aug 19, 2014 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    I'm confused... what are you talking about? <a>-tag in the <form>? How, what? Hidden form?
    I'm assuming you've already got a form to fill the GET-variables - you just change the method to post... I don't understand how this changes anything. Nor why working in root-directory or not has anything to do with the problem...
    Besides, you can still use $_GET to add the user_id onto the URL - and then just pull the information you need on the second page based on the ID passed via the URL.
     
    PoPSiCLe, Aug 20, 2014 IP
  6. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #6
    I'm just talking about hiding or obscuring url in the status bar and in the address bar of the page it go to after clicking.

    The current method I use is something like this (Can't remember the exact code):
    <form id="myform" name="myform" method="POST" action="nextpage.php">
       <input type=hidden id=xxxx name=id value=yyyy />
       <input type=hidden id=aaaa name=email value=bbbb />
       <a href="javascript:function(){}" onclick="document.getElementById('myform').submit()">Go</a>
    </form>
    Code (markup):
    But I want to do something like this instead, so it won't break my original design.
    <a herf="nextpage.php?id=xxxx&email=yyyy">Go</a>
    Code (markup):
    sorry about root directory, just thinking out loud :)
     
    ketting00, Aug 21, 2014 IP
  7. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #7
    I think you should look at the design (not the look) of your site. This seems unnecessary convoluted and bad code.
     
    PoPSiCLe, Aug 21, 2014 IP
  8. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #8
    I'm intrigued. What should be the better code. I use this practice for very very long time. Any suggestions should be appreciated.

    Thank you,
     
    ketting00, Aug 21, 2014 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  10. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #10
    Having used one way of coding for a long time doesn't make it the right way to do it.
    Automatic submit via javascript of a hidden form seems to me like a method that should have died silently during the 90s - especially if it's submitting information that shouldn't be submitted and openly available anyway.
    As nico_swd said - use sessions. Or cookies (albeit it's not recommended), or just pass an identifier (for instance a user_id) to the different pages, and pull the needed information on each page. There are so many ways that are better than the presented option.
     
    PoPSiCLe, Aug 21, 2014 IP
    ketting00 likes this.
  11. Jameyson MacDonald

    Jameyson MacDonald Well-Known Member

    Messages:
    452
    Likes Received:
    83
    Best Answers:
    3
    Trophy Points:
    115
    #11
    Why would you want to encrypt an url?
     
    Jameyson MacDonald, Aug 21, 2014 IP
  12. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #12
    Well, following PoPSiCLe suggestions. I don't think I need it anymore. It's my fault for lacking advanced PHP skills, I guess.
     
    ketting00, Aug 21, 2014 IP
  13. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #13
    ... and you're not using a input[submit] instead of that stupid malfing idiotic halfwit scripttardery on an anchor why exactly?!? No offense but that has to be one of the DUMBEST things I've ever seen done on a form.
     
    deathshadow, Aug 21, 2014 IP
  14. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #14
    Back in 2007 or 2008, they said Facebook once use hidden form to pass data around its site. I think it was good. My Google search lands me exactly to that solution. Bingo! I use it ever since.

    After this point, no more stupid malfing idiotic halfwit scripttardery on an anchor exactly :)
     
    Last edited: Aug 21, 2014
    ketting00, Aug 21, 2014 IP
  15. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #15
    It works, by all means, but it's not a good way to code - and it leads to, for instance, passing of values you don't want passed, passing of values before they're ready, etc. But it seems you've gotten good advice in this thread, and hopefully, you'll be able to keep the design as is, by modifying a bit of background code :)
     
    PoPSiCLe, Aug 22, 2014 IP