Jump to content

isset help


adavison2

Recommended Posts

why dose this not work

 

<?php

 

if(isset($_SESSION['SESS_ADMIN']))

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

else

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

 

                     

?>

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

</body>

 

</HTML>

Link to comment
Share on other sites

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