This topic is locked

Users only seeing their own details

9/21/2006 1:24:29 PM
PHPRunner General questions
T
tim.latham author

I have set phpRunner up so that users need to login and can only view/edit/delete their own record. Therefore is it possible to take users directly to the "Edit" page upon logging in rather than them going initially to the "List" page" - as almost certainly any user logging in to my system will be wanting to "Edit" their details rather than anything else. I would not be concerned if users lost the ability to "Delete" their own records as this could be dealt with be me as administator.
Thanks.

Sergey Kornilov admin 9/21/2006

You can use AfterSuccessfulLogin Event for this purpose. Here is the piece of code that does the job. If user has several records assigned to him he will be always redirected to the first one. If user don't have any records he will be redirected to the Add page.

function AfterSuccessfulLogin()

{
global $conn;
if ($_SESSION["AccessLevel"] != ACCESS_LEVEL_USER)

return;
$strSQLExists = "select * from cars where userid=" . $_SESSION["OwnerID"];

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

//********** Redirect user to the edit page ************

header("Location: cars_edit.php?editid1=".$data["ID"]);

exit();

}

else

{

//********** Redirect user to the add page ************

header("Location: cars_add.php");

exit();

}
}