-1

So I have a site in which people have specific accounts. After login, I want them to be directed to a homepage specific to them (like a account page, with info about their account, new chats, etc.). How would I redirect them to their own account page after they login? All of the code came from http://www.tutorialrepublic.com/php-tutorial/php-mysql-login-system.php, which simply redirects a user to welcome.php. I tried adding welcome.php?id=# to the end of the URL, but that didn't work. I'm new to PHP/MySQL, so I used the tutorial for my login system. I can code adequately in HTML, so thorough explanations of solutions would be appreciated, however, any functioning code would be appreciated. Thank you!

Edit: I don't want to just redirect people from one page to another page, I want each user to be taken to their profile. For example, if user1 logs in, I want them to be sent to their profile page (with editing powers), not to welcome.php. However, user2 shouldn't go to the same page, they should go to their own profile page.

  • 1
    You are expected to try to **write the code yourself**. After [**doing more research**](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Jay Blanchard Jun 21 '17 at 19:00
  • Trust me, I tried to write all of the code myself, but I couldn't do so. My attempts were insecure and nonfunctional. As such, I followed the tutorial on that site. I will add what code I tried, but I'm not sure that it will help anyone with answering the question. – user54345349 Jun 21 '17 at 19:07
  • 1
    @user54345349 you question is not make sense. However, you look like new bie and you facing issue in login redirection. I suggest you go thru this tutorial https://speedysense.com/create-registration-login-system-php-mysql/ here you see login page wrote header `dashboard.php` may be you are looking this. – Jaykumar Patel Dec 17 '19 at 07:00

2 Answers2

1

PHP makes redirect using header() function, for example

header("location: /your_page.php");
Ivan Bolnikh
  • 742
  • 9
  • 19
0

What you're asking for is very vague. However, from what I gather it seems you want to redirect a user to a "preferred page" after successful login?...

If so you can use the following.

header('Location: your_path_here.php');

put this at the end of your successful logic check on your process page.

Shane A. Workman
  • 112
  • 2
  • 16
  • What I want is when a user logs in, they are redirected to page that only they can access, such as in Stack Overflow, after you login in, you are directed to https://stackoverflow.com/users/####/username. – user54345349 Jun 21 '17 at 19:11
  • pass the new page a param via query string. IE your_path_here.php?param – Shane A. Workman Jun 21 '17 at 19:29