plodos Posted December 24, 2008 Share Posted December 24, 2008 if I login the system as a reviewer, login_control.php must open the reviewer.php page id username password email type 1 p p a@a reviewer login_control.php <?php $sql="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched table row must be 1 row if($count==1){ $row = mysql_fetch_array($result); $_SESSION['loggedIn'] = $row['type']; $_SESSION['id'] = $row['id']; header("location:{$row['type']}.php?"); } ?> but problem starts here. My username and password is true, and type is reviewer. when I try to login the system as a reviewer, header("location:index.php"); is open the index page. WHY ? reviewer.php <?php include('dbconfig.php'); session_start(); if ($_SESSION['loggedIn'] != 'reviewer') { //check the registered user, if not go index.php if(!$_SESSION['id']) { header("location:index.php"); die(); } else //if registered with different user type turn back to your page { echo " <script language='JavaScript'>history.go(-1);</script>"; } } else { //open the secure page } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 Looks like if(!$_SESSION['id']) is routing you, not $_SESSION['loggedIn'] Echo $_SESSION['id'] and see what it contains. Quote Link to comment Share on other sites More sharing options...
plodos Posted December 24, 2008 Author Share Posted December 24, 2008 there are the errors when I try to login as a reviewer with reviewer information Notice: Undefined index: loggedIn in /home/bbp/reviewer.php on line 6 Notice: Undefined index: id in /home/bbp/reviewer.php on line 8 Notice: Undefined index: id in /home/bbp/reviewer.php on line 12 Notice: Undefined index: loggedIn in /home/bbp/reviewer.php on line 13 Quote Link to comment Share on other sites More sharing options...
plodos Posted December 24, 2008 Author Share Posted December 24, 2008 if($count==1){ $row = mysql_fetch_array($result); $_SESSION['loggedIn'] = $row['type']; $_SESSION['id'] = $row['id']; header("location:{$row['type']}.php?id={$row['id']}&type={$row['type']}"); } http://aaaa.com/reviewer.php?id=9&type=reviewer ID is true, TYPE is true BUT why this part is working FALSE, WHY header("location:index.php"); is working ???? Please help me <?php include('dbconfig.php'); session_start(); if ($_SESSION['loggedIn'] != 'reviewer') { //check the registered user, if not go index.php if(!$_SESSION['id']) { header("location:index.php"); die(); //echo $_SESSION['id']; //echo "<br>".$_SESSION['loggedIn']; } else //if registered with different user type turn back to your page { echo " <script language='JavaScript'>history.go(-1);</script>"; } }else{ //page starts here ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 I dont see session_start() on login_control.php Quote Link to comment Share on other sites More sharing options...
plodos Posted December 24, 2008 Author Share Posted December 24, 2008 you are right when i change the code but i forgot to put session thank you one more time revraz Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.