cottonbuds2005 Posted October 10, 2009 Share Posted October 10, 2009 Im very new to php and mysql databases. This logout script doesnt work, doesnt re-direct to the index.php page. Any help will be greatly appreciated. Thank you very much _____________________________________________________________________________________ <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "index.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "Administrator"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "failed.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IT Inventory Database</title> <link rel="stylesheet" type="text/css" href="files/stylesheet/style.css"> </head> <body><h3>IT Inventory Database</h3> <table> <tr> <td><form id="create" name="create" method="post" action="files/create.php"> <input name="create" type="submit" class="mainbtn" id="create" value="Create New Record" /> </form> </td> <td><form id="view" name="view" method="post" action="files/ITDB.php"> <input name="view" type="submit" class="mainbtn" id="view" value="View IT Database" /> </form></td> </tr> <tr> <td><form id="deleterecord" name="deleterecord" method="post" action="files/DeleteITDB.php"> <input name="delete" type="submit" class="mainbtn" id="search2" value="Delete Record" /> </form></td> <td><form id="results" name="results" method="post" action="files/ITFAResults.php"> <input name="results" type="submit" class="mainbtn" id="search" value="IT and FA Reconciliation Result" /> </form></td> </tr> <tr> <td><form id="update" name="update" method="post" action="files/UpdateITDB.php"> <input name="update" type="submit" class="mainbtn" id="update" value="Update Record" /> </form></td> <td><form id="results" name="results" method="post" action="files/ITEPOResults.php"> <input name="results" type="submit" class="mainbtn" id="search" value="IT and EPO Reconciliation Result" /> </form></td> </tr> <tr> <td><form id="search" name="search" method="post" action="files/Search.php"> <input name="search" type="submit" class="mainbtn" id="search" value="Search Record" /> </form></td> <td><form id="ITEPOresults" name="ITEPOresults" method="post" action="#"> <input name="results" type="submit" class="mainbtn" id="search" value="-" /> </form></td> </tr> <tr> <td><form id="SearchandUpdate" name="SearchandUpdate" method="post" action="files/SearchandUpdate.php"> <input name="SearchandUpdate" type="submit" class="mainbtn" id="SearchandUpdate" value="Search and Update Record" /> </form></td> <td><form id="ITEPOresults" name="ITEPOresults" method="post" action="#"> <input name="results" type="submit" class="mainbtn" id="search" value="-" /> </form></td> </tr> <tr> <td colspan="2"><form name="form1" id="form1" method="post" action=""> <div align="center"> <form action="<?php echo $logoutAction ?>" method="post"><input type="submit" name="Submit" value="Logout" /> </form></td> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/177193-logout-script-problem-pls-help/ Share on other sites More sharing options...
MadTechie Posted October 10, 2009 Share Posted October 10, 2009 1. please use code tags, 2. your have a open tag for a form then another open tag for a form.. remove the first one <td colspan="2"><form name="form1" id="form1" method="post" action=""> <div align="center"> <form action="<?php echo $logoutAction ?>" method="post"><input type="submit" name="Submit" value="Logout" /> </form></td> should be <td colspan="2"> <div align="center"> <form action="<?php echo $logoutAction ?>" method="post"><input type="submit" name="Submit" value="Logout" /> </form></td> 3. view source to check the action has doLogout=true Link to comment https://forums.phpfreaks.com/topic/177193-logout-script-problem-pls-help/#findComment-934337 Share on other sites More sharing options...
cottonbuds2005 Posted October 10, 2009 Author Share Posted October 10, 2009 Thank you so much MadTechie. It worked... Link to comment https://forums.phpfreaks.com/topic/177193-logout-script-problem-pls-help/#findComment-934437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.