advice on best solution to use
Posted on 2006-11-09
some background information:
i have a PHP page, that when viewed, is customised to the user viewing it. how i detect which user is viewing the page is by using an Java applet that i built to POST the username that windows stores after you login to our network. in my PHP page i get that username like: $username = trim($_GET['username']);
the issue im facing and needing advice on is this:
when i get the username, i query MS SQL to get the users details stored in our system and i register a session. (after i register my session, i can then customise the PHP page for that user)
now if the username is blank - i want to redirect to an error page as either the user has tired to edit the username in URL or the username didnt get posted correctly to the PHP page from the Java Applet (HTML page).
now i also want to check if the session is set or not (empty). if its already set, skip the process of setting the session the second time around if user refreshes the PHP page. if the session isnt set, the obviously set the session and show the PHP page customised to that user.
But regardless of whether the session is set or not, my users are always redirected to error page...
my current code:
$username = trim($_GET['username']);
$_SESSION['user_info'] = array();
// DB connection string here
// DB query string that uses $username and the result string of that query here
while ($row = mssql_fetch_array($results))
$_SESSION['user_info']['persid'] = trim($row['PersID']);
$_SESSION['user_info']['surname'] = trim($row['Surname']);
$_SESSION['user_info']['firstname'] = trim($row['Firstname']);
// Close DB connection here
// Rest of HTML tags here that is used to customise the page for the user