Jump to content

$_SESSIONS being passed to one page but not the other, help!!


gammaman

Recommended Posts

I have a page set up with sessions like this

(checkUser.php)

<?php
$Conn=mysql_connect("localhost","fierm","13183");

if(!$Conn){
   echo "failed";
  }
  else{
  
mysql_select_db("fierm");
echo "here";

session_start();
if (!isset($_SESSION['checkUser']['user']))  {


$_SESSION['checkUser']=$_POST;

$_SESSION['checkUser']['user'];

$_SESSION['checkUser']['pass'];

}
echo "{$_SESSION['checkUser']['user']}";
echo "{$_SESSION['checkUser']['pass']}";
$result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['checkUser']['user']}' 
                 and password='{$_SESSION['checkUser']['pass']}'");
  $cou=mysql_num_rows($result);
  
  if($cou>0) 
  {
      echo "Student validated";
      echo "<br />";
      echo "<a href=\"student.php\">Student Page</a>";
  }

  elseif(("{$_SESSION['checkUser']['user']}"=="root") && ("{$_SESSION['checkUser']['pass']}"=="pwd123")){
      echo "<a href=\"admin.php\">Admin Page</a>";
     
   }

  
else{
    
      echo "Invalid Password";
      echo "<a href=\"main.php\">Login Again</a>";
     }    
}
?>

AND This page receieves it

(admin.php)

<?php
$Conn=mysql_connect("localhost","fierm","13183");

if(!$Conn){
   echo "failed";
  }
  else{
  
mysql_select_db("fierm");

  session_start();
  $_SESSION['checkUser']['user'];

  $_SESSION['checkUser']['pass'];

   
  echo "<a href=\"addCourse.php\">Add Courses</a>";
  echo "<br />";
  echo "<a href=\"addStudent.php\">Add Student</a>";
  echo "<br />";
  echo "<a href=\"addGrades.php\">Input Grades</a>";

   


}
?>

But This page does NOT

(student.php)

<body>
<b>Student Login</b>	


<?php
$Conn=mysql_connect("localhost","fierm","13183");

if(!$Conn){
   echo "failed";
  }
  else{
  
mysql_select_db("fierm");

   

session_start();
  $_SESSION['checkUser']['user'];
  $_SESSION['checkUser']['pass'];

echo "{$_SESSION['checkUser']['user']}";  //Nothing is echoed

echo "{$_SESSION['checkUser']['pass']}"; //Nothing is echoed





  
$result=mysql_query("select studentID, password FROM Student WHERE studentID='{$_SESSION['checkUser']['user']}' 
                 and password='{$_SESSION['checkUser']['pass']}'");
  $cou=mysql_num_rows($result);
  echo "$cou";
  
  if($cou>0) 
  {
      echo "<table border=\"1\">";
      echo "<b>Registered Courses</b>";
      echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade</th></tr>";
    
      $result1=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['checkUser']['user']}'");
      $cou=mysql_num_rows($result1);
    
      while($row=mysql_fetch_array($result1))
      {
      
       echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[3]</td></tr>\n";

      }
     
     echo "</table>";

     
     echo "<b>Register For Courses:</b>";
     echo "<br />";
     echo "<a href=\"regCourse.php\">Register Courses</a>";
     echo "<b>Drop a Course:</b>";
     echo "<br/>";
     echo "<a href=\"dropCourse.php\">Drop a Course</a>";


     
    }
  



     
    
  
}
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.