adavison2 Posted January 19, 2011 Share Posted January 19, 2011 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> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 19, 2011 Share Posted January 19, 2011 In what way does it not work? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 19, 2011 Share Posted January 19, 2011 if (what you tell us = A - what you expect it to do && B - what it actualy does && C - what the rest of the relevant code is) {we can help} else {you got no chance} Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 19, 2011 Share Posted January 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 19, 2011 Share Posted January 19, 2011 That won't help certainly, but I don't think there may be a small issue in here too : $loc = ../admin/admin.php; else $loc= ../head/head.php"; Quote Link to comment Share on other sites More sharing options...
adavison2 Posted January 19, 2011 Author Share Posted January 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 19, 2011 Share Posted January 19, 2011 When posting code, please enclose it in the forum's . . . BBCode tags, as I have done for you this time. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted January 19, 2011 Share Posted January 19, 2011 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. Quote Link to comment Share on other sites More sharing options...
adavison2 Posted January 19, 2011 Author Share Posted January 19, 2011 done it with if ($_SESSION['SESS_ADMIN'] == "admin") { $loc= "../admin/admin.php"; } elseif($_SESSION['SESS_HEADTEACHER'] == "head") { $loc = "../head/head.php"; } Quote Link to comment Share on other sites More sharing options...
adavison2 Posted January 19, 2011 Author Share Posted January 19, 2011 thanks for all the help 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.