Jump to content

Cannot log user out...


ActaNonVerba1

Recommended Posts

Hey guys im making a script which allows a user to log in.

Then view some data from an SQL file, then click to a log out page and log out...

However i cant seem to destroy the session.

Any help?

 

Heres logout.php

<?php
$_SESSION['adminlogin'];
session_start();
$_SESSION = array();
session_destroy();
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
<article>
<?php
echo '<h1 class="Title">Successfully Logged Out</h1>';
?>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

If you need any of the other files, ask and ill provide.

Thanks in advance.

 

Danny

 

Link to comment
Share on other sites

Hey guys im making a script which allows a user to log in.

Then view some data from an SQL file, then click to a log out page and log out...

However i cant seem to destroy the session.

Any help?

 

Heres logout.php

<?php
$_SESSION['adminlogin'];
session_start();
$_SESSION = array();
session_destroy();
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
<article>
<?php
echo '<h1 class="Title">Successfully Logged Out</h1>';
?>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

If you need any of the other files, ask and ill provide.

Thanks in advance.

 

Danny

 

session_start() would come before you declare a session shouldn't it? Also, what is the purpose of $_SESSION = array(), $_SESSION is already an array.

Link to comment
Share on other sites

neither of your things seem to work for me.

 

Here are all the pages, can you look over them for me please?

 

Page log in form:

<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>

<article>
    <h1 class="Title">Log In To Admin</h1>
  <div class="Textbox"> 
      <form id="adminlogin" action="Log-In-Accept-Deny.php" method="post">
      <div style="float:left; width:100px;">
      <p>Username</p>
      <p>Password</p>
      </div>
      <input type="text" name="username" style="margin-top:13px;"><br>
      <input type="password" name="password" style="margin-top:11px;"><br>
      <input type="submit" value="Log In"> 
      </form>
      <br>
    </div>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

Heres the page you go to after the form page, which decides if you are allowed on or not

<?php
    $username = $_POST['username'];
$password = $_POST['password'];
	if ($username==Danny) {
		if($password==loyalhatter15) {
			$deniedallowed = "Welcome to the Admin Panel, Michael";
				////////////////////////////////////////////////////////////
				session_start();
				$_SESSION['adminlogin'] = 1; // store session data
				////////////////////////////////////////////////////////////
		}
		else {$deniedallowed = "Access Denied";}
	}
else {$deniedallowed = "Access Denied";}
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
        <?php
	if ($showlogoff=1) {
		echo '<div id="logout">
			  <div style="float:left; width:30%; text-align:left;!important">
			  <a href="Log-In-Accept-Deny.php">Back to Admin Home</a></p>
			  </div>
			  <div style="float:right; width:70%;">
			  <a href="Logout.php">Log Out of Admin</a>
			  <p style="font-size:10px;">Always Sign Out when Finished!</p>
			  </div></div>';}
?> 
<article>
    <?php
echo '<h1 class="Title">'.$deniedallowed.'</h1>';
echo '<div class="Textbox">';
if ($deniedallowed == "Access Denied") {
echo 'Username/Password combination is wrong. Please try again, or stop trying ot hack the system!';
}
else {
echo 'Welcome to the admin panel, what do you want to do?';
echo '<ul>
		<li><a href="Admin.php">See Newsletter Sign Ups</a></li>
	  </ul>';	
}
if ($_SESSION['adminlogin'] == 1){
	echo "Logged in on server side.";
}
echo '</div>';
?>
      <br>
    </div>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

Heres the page i want people to only view after theyve logged in

<?php
 if($_SESSION['adminlogin']=1) {
	 $showlogoff=1;
}
else {
    header('Location: http://www.worldwidelighthouses.com/Newsletter/Admin/Log-In.php');
	exit;
if(!$_SESSION['adminlogin']) { die('not logged in');}
}?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
        <?php
	if ($showlogoff=1) {
		echo '<div id="logout">
			  <div style="float:left; width:30%; text-align:left;!important">
			  <a href="Log-In-Accept-Deny.php">Back to Admin Home</a></p>
			  </div>
			  <div style="float:right; width:70%;">
			  <a href="Logout.php">Log Out of Admin</a>
			  <p style="font-size:10px;">Always Sign Out when Finished!</p>
			  </div></div>';}
?> 
<article>
    <h1 class="Title">Contact Admin Centre</h1>
  <div class="Textbox"> 
      <?php 
	$user="worldw44_php";
	$password="c@rtmeldrive41";
	$database="worldw44_newsemail";
	mysql_connect(localhost,$user,$password);
	@mysql_select_db($database) or die( "Unable to select database, please try again later.");
	$query="SELECT * FROM contactinfo";			
	$result = mysql_query ($query) or die(mysql_error()); //Everything in MySQL Database
	$num=mysql_numrows($result); //Find number of rows of MySQL Database
	$i=0; //Number of times loop to show data has run, starts a 0 like MySQL database
	while ($i < $num) {
	$name=mysql_result($result,$i,"name"); //Loop takes data from name
	$email=mysql_result($result,$i,"email"); // and email
	echo "<b>$name</b><br>Email: $email<br><hr><br>";
	$i++; //Adds to i to tell how many loops, and which row from MySQL to read from.
	}		
  ?>
      <br>
    </div>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

And heres the log out page as of now...

 

<?php
session_start();
$_SESSION['adminlogin'];
session_unset();
session_destroy();
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Mailing List Administration | Worldwide Lighthouses</title> 
            </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="../Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="../Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="../Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="../Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="../Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="../Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="../Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
<article>
<?php
echo '<h1 class="Title">Successfully Logged Out</h1>';
?>
</article>
    <footer>
    <ul>
    	<li><a href="../About.php">About</a></li>
        <li><a href="../Contact-us.php">Contact</a></li>
        <li><a href="../Use-Our-Media.php">Use our media</a></li>
        <li><a href="../Search/search.php">Search</a></li>
        <li><a href="../Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

Any help?  :wtf:

 

Link to comment
Share on other sites

Well, the way you form your braces around conditionals makes it a pain to read, but first you should work on your assignment statements.

 

this = that will always return true because in the statement you're assigning this to that, you want to use the equal operator - ==

 

Best example is this:

if($_SESSION['adminlogin']=1) {

 

That's always going to be true, even if the adminlogin session isn't set.

 

Demonstration:

$zero = 0;

if($zero=1) 
{
echo "Zero equals 1, wtf?";
}

 

That will always put out the echo statement.

 

Change up that stuff first, see if it changes anything.

Link to comment
Share on other sites

Heres the page i want people to only view after they've logged in

 

^^^ You would need a session_start(); statement on that page (any page that sets or references a $_SESSION variable needs a session_start() statement.)

 

If your login code is not working, you need to troubleshoot it first before you worry about any of the other code.

 

I see some code in the login page that would be producing runtime notice/warnings. Are you developing and debugging your code on a system with error_reporting set to E_AL and display_errors set to ON so that all the php detected errors will be reported and displayed? You will save a TON of time.

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.