Forum Moderators: coopster
<?php
//error_reporting(E_ALL|E_STRICT);
require_once("Connections/connection.php"); // Connection to the server
session_start();
$tbl_name="users"; // Define the table name
//include("includes/security.php"); //Link to the security file
$id = $_SESSION['id'];
////////////////////////////////////////////////////////////////////////////////////
$query = "SELECT * FROM `users` WHERE `username` = '".$id."' ";
$result = mysql_query($query) or die("Query error:".mysql_error());
$rowAccount = mysql_fetch_array($result);
////////////////////////////////////////////////////////////////////////////////////
?>
<div id="user_box">
<?php
if(isset($_SESSION['id']) && !empty($_SESSION['id'])){
echo 'Logged in as '. $rowAccount['username'];
echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
}
?>
</div>
<div id="user_box">
<?php
if(isset($_SESSION['id']) && !empty($_SESSION['id'])){
echo 'Logged in as '. $rowAccount['username'];
echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
}
elseif{
//redirected from the logoff script after the button being clicked
echo 'You are now logged out'
}
?>
</div>
<?php
session_start();
session_destroy();
header("location:index.php");
exit;
?>
<div id="user_box">
<?php
if(isset($_SESSION['id']) && !empty($_SESSION['id'])){
echo '<p>Logged in as '. $rowAccount['username'] . '</p>
<form method="get" action="logout.php">
<input type="submit" name="Button" value="Logout">
</form>
';
}
else {
if (isset($_GET['logout_variable'])) {
echo '<p>You have successfully logged out.</p>';
}
echo '
<form method="post" action="login-script.php">
<!-- presuming uname and pass here -->
<input type="submit" value="Log In">
</form>
';
}
?>
</div>