Forum Moderators: coopster

Message Too Old, No Replies

User Authentication and Redirection

         

mkaiser

1:43 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



I know some of you probably heard this request a million of times already but I couldn't find anything and I am desperate now.
My website needs an area where my customers can log in and where they can pull invoices and stuff like that. I have a login system that validates the user trough MySQL. But they are all ending up on the same page. The problem is that I can't have one customer look at the other customers invoice. How would I redirect a user automatically to their own space on the MySQL database and being able to look only at his information. I tried two different programs. I really like Rakinks User Manager but I don't know php well enough to redirect a logged in user. And I tried phpguarddog which has redirection but the program itself is not my favorite.
If anyone could help me in the right direction I would appreciate it.

mattx17

3:57 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



The method I would use is after they are successfully logged in, save their unique user id (if they don't have one, make it so they do) into a session variable, for example:

if ($LoginSuccessful)
{
$_SESSION['UserID'] = $Row['UserID'];
header("Location: invoices.php");
}

Then on the invoices.php page:

$SqlStmt = "select * from tblInvoices where UserID = '" . $_SESSION['UserID'] . "'";

etc etc

Hope this helps!

jatar_k

7:14 pm on Feb 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



and Welcome to WebmasterWorld mkaiser

mkaiser

12:25 am on Feb 21, 2005 (gmt 0)

10+ Year Member



Thanks for the help mattx17. I will try out and hopefully it will work for what I will use it for. Thanks also for the welcome jatar_k. I was so busy last couple of days that I couldn't thanks you guys earlier.