Skip to content
Advertisement

Redirect based on the ?id= parameter in the url

I have a login system that I build in PHP and MySQL. if any of my users log in they get directed to the user.php page

I have an authenticate.php page that redirects the user based on their ID to a page. This is the code that adds the id to the URL: header(“Location: user.php?id=”.$id); )

JavaScript

Can I write a javascript function on the original user.php file that will read the user ID in the URL and redirect to a specific page on my site?

Example:

User 1 needs to go

from: http://www.mysite/user.php?id=1

To: http://www.mysite/dashboard/clientA/home.php

User 2 needs to go

from: http://www.mysite/user.php?id=2

To: http://www.mysite/dashboard/clientB/home.php

Advertisement

Answer

Hi you can do the following:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement