Jump to content

Issue with Sessions


gammaman

Recommended Posts

I have a page that uses sessions received from a form on the previous page.  If I enter an invalid user name and password it falls into the else as it should.  However if I return to the log in page is indicated in the else clause, and I enter the valid user name and password, it still says it is invalid.  I think I may need to unset the sessions when it falls into the else but I am not sure.  Here is the code.

 

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

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

session_start();
if (!isset($_SESSION['admin']['admins']))  {


$_SESSION['admin']=$_POST;

$_SESSION['admin']['admins'];

$_SESSION['admin']['adminpass'];

}


  if(($_SESSION['admin']['admins'] == "root") && ($_SESSION['admin']['adminpass']=="pwd123")){  
   
  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>";
}

else{
    echo "Invalid Password, Return To Login";
    echo "<br/>";
    echo "<a href=\"alog.php\">Login</a>";
   


}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/103407-issue-with-sessions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.