How to automatically generate and redirect the link in the header

0

I need to generate a system where I have a template page (the fb profile for example) and that will be fed by my database with the information according to a user ID. My problem is: I do not want the link of the passed parameter (id) to be exposed in the header of the page, but rather a variable of that user that gave the query (the user of it for example) and that at the same time if I access that link .mysite.com / user) it is redirected to that same page (giving the query in the DB and pulling the information normally)

Is this possible via PHP or JS?

Thank you in advance!

    
asked by anonymous 17.02.2018 / 03:40

1 answer

1

Yes, it is possible,

To set up the page url, see these links: How to Make Friendly URL or How do I make a friendly url in PHP

For testing you can get the current url with $_SERVER["REQUEST_URI"]

With JS there is a question here in StackOverflow about picking url from previous page

With the value of this url you can use the functions substr() to get the value after the "/" and send to the control of your system, there you make the query passing this value

To send id of user without being $_GET you can use $_SESSION or $_POST

    
17.02.2018 / 05:19