I just got out of my ASP cave recently and am having trouble setting up PHP for sunlight.
My current problem is a simple logical sequence in which I create a session variable - this step causes my browser to freeze and then act randomly.
On my login page (A.php), the login form is directed to B.php (below), which processes the password, creates a session variable, and then redirects the user to another file (C.php).
For brevity, I simply assume that the login is successful. B.php contains the following:
<?php session_start(); require "../scripts/base/toolbox.php"; fnProcessLogin(); function fnProcessLogin(){ $passwd = strtoupper($_POST["passwd"]); if (strlen($passwd)==0) { $passwd=strtoupper($_SESSION['plpassword']); unset($_SESSION['plpassword']); } try{ $db = Database::getDB(); $sql="SELECT securitylevel, staffID, staffname, stafflname, staffemail, iRoleID FROM staff WHERE staffpasswd=?;"; $data = array($passwd); $query = $db->prepare($sql); $query->execute($data); if($query->rowCount()>0){ $row = $query->fetch(); $a=$passwd."|".$row['staffID']."|".$row['staffname']."|".$row['stafflname']."|".$row['staffemail']."|".$row['iRoleID']; $_SESSION['admin'] = $a; header('Location: C.php'); } } catch(PDOException $pe){ echo "We are sorry, but we cannot complete this database operation."; file_put_contents('PDOerrors.txt',$pe->getMessage(),FILE_APPEND); } } ?>
If I comment "$ _SESSION ['admin'] = $ a;" line, the redirection works fine, but as soon as I try to create this session variable, my browser freezes until it switches to C.php, where it cannot load files properly. The action of the back button seems to put the browser in an endless loop.
What is this caveman doing wrong?
Thanks,
Brian.
Bruce source share