Jump to content

isset help


adavison2

Recommended Posts

Actually, in spite of the fact that there's no description of the problem, it probably doesn't work because there's no session_start(); called at the beginning of the script, therefore this: if(isset($_SESSION['SESS_ADMIN'])) will never evaluate to TRUE.

Link to comment
https://forums.phpfreaks.com/topic/224965-isset-help/#findComment-1161947
Share on other sites

below is full code the session is set when a administrator logs on or headteacher logs on what i want it to do is if they are a administrator and click main menu they get sent to admin main menu if they are a hearteacher they get sent to the head teacher main menu

it all worksup to the if(isset($_SESSION['SESS_ADMIN'])) it causes a error

 

<?php
ob_start();

if(!isset($_SESSION)) 
{ 
session_start(); 
}  

require_once('../auth.php');
?>

<Head>
<link href="../loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
   font-size: 18px;
   font-weight: bold;
}
.style3 {font-size: 36px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; }
-->
</style>
</head>
<body>


<?php

require_once('../config.php');   
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
   if(!$link) {
      die('Failed to connect to server: ' . mysql_error());
   }
$db = mysql_select_db(DB_DATABASE);
   if(!$db) {
      die("Unable to select database");
   }


?>

<HTML>
<h1>Reporting Online</h1>

<P>Signature Archive</P>
<P>

<?php
$path = ".";
$dir_handle = @opendir($path) or die('Unable to open $path');

while (false !== ($file = readdir($dir_handle))) {

// Prevent this file itself being shown
if($file == "signfile.php")
continue;
// Prevent this file itself being shown
if($file == "uploader.php")
continue;

// Prevent this file itself being shown
if($file == "delete.php")
continue;

if($file == "makeactive.php")
continue;

if($file == "activate.php")
continue;


// Prevent this file itself being shown
if($file == ".")
continue;

// Prevent this file itself being shown
if($file == "..")
continue;
echo "<a href=$file>$file</a>";
?>

<?php
echo "<BR>";
}
?>

<FORM METHOD="LINK" ACTION="activate.php">
<INPUT TYPE="submit" VALUE="Activate a Signature">
</FORM>
<h1></h1>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
Choose a file to upload to the signature archive: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
<h1></h1>
</P>
Delete a file from the signature archive<BR>

<?php
// open the current directory
$dhandle = opendir('.');
// define an array to hold the files
$files = array();

if ($dhandle) {
   // loop through all of the files
   while (false !== ($fname = readdir($dhandle))) {
      // if the file is not this file, and does not start with a '.' or '..',
      // then store it for later display
      if (($fname != '.') && ($fname != '..') &&
          ($fname != basename($_SERVER['PHP_SELF']))) {
          // store the filename
          $files[] = (is_dir( "./$fname" )) ? "(Dir) {$fname}" : $fname;
         
      }
   }
   // close the directory
   closedir($dhandle);
}
?>

<form enctype="multipart/form-data" action="delete.php" method="POST">
<input type="hidden"  />
<select name= "deletefile">

<?php
// Now loop through the files, echoing out a new select option for each one
foreach( $files as $fname )
{
        // Prevent this file itself being shown
if($fname == "signfile.php")
continue;
// Prevent this file itself being shown
if($fname == "uploader.php")
continue;

// Prevent this file itself being shown
if($fname == "delete.php")
continue;

if($fname == "activate.php")
continue;

if($fname == "makeactive.php")
continue;


// Prevent this file itself being shown
if($fname == ".")
continue;
   echo "<option> $fname </option>";
}
echo "</select>";
?>
<input type="submit" value="Delete" />
</select>
</form>
<h1></h1>



<?php

if(isset($_SESSION['SESS_ADMIN']))
   $loc = ../admin/admin.php;
else
   $loc= ../head/head.php";

//$loc = "../admin/admin.php";

                      
?>
<form><INPUT TYPE="button" value="Main Menu" onClick="parent.location='<?php echo $loc; ?>'"></form>
</body>

</HTML>

 

MOD Edit: code tags added.

Link to comment
https://forums.phpfreaks.com/topic/224965-isset-help/#findComment-1161960
Share on other sites

ok, do you get the same error if you log in as a head and admin users?

 

you can try

if(isset($_SESSION['SESS_ADMIN']))
   $loc = "http://" . _SERVER['PHP_HOST'] . "/admin/admin.php";
else
   $loc= "http://" . _SERVER['PHP_HOST'] . "/head/head.php";

 

if that doesn't help posting what the actual error is will.

Link to comment
https://forums.phpfreaks.com/topic/224965-isset-help/#findComment-1161975
Share on other sites

done it with

if ($_SESSION['SESS_ADMIN'] == "admin") {
                           $loc= "../admin/admin.php";
                           }
                      elseif($_SESSION['SESS_HEADTEACHER'] == "head") {
                         $loc = "../head/head.php";
                       }

Link to comment
https://forums.phpfreaks.com/topic/224965-isset-help/#findComment-1162000
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.