PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
session_start();
if(!isset($_REQUEST['logmeout'])){
include 'headermem.php';
echo "<center>Are you sure you want to logout?</center>";
echo "<center><a href=logout.php?logmeout=true>Yes</a> |
<a href=javascript:history.back()>No</a>";
include 'footermem.php';
} else {
session_destroy();
if(!session_is_registered('username')){
$msga = "You are now logged out ! Please come back soon!";
echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>";
include '../index.php';
exit();}
}
?>
So as long as you don't have ?logmeout=true in the url or post then you should see the confirmation link. Try viewing the source of the html.. you may have some malformed html
A couple of other things,
- Why are you using $_REQUEST, if you are expecting data from a specific source then use the appropriate super global. i.e. $_GET
- session_is_registered() is deperecated, simply use isset($_SESSION['username'])
<?php
session_start();
if(!isset($_REQUEST['logmeout'])){
include 'headermem.php';
echo "<center><font color=white><font face=calligraphic><strong>Are you sure you want to logout?</strong></font></center><br />";
echo "<center><a href=logout.php?logmeout=true>Yes</a> |
<a href=javascript:history.back()>No</a>";
include 'footermem.php';
} else {
session_destroy();
if(!session_is_registered('username')){
$msga = "You are now logged out ! Please come back soon!";
echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>";
include '../index.php';
exit();}
}
?>
<?php
session_start();
// Check a positive return, not a negative
if (isset($_GET['logmeout']))
{
session_destroy();
// I would probably get rid of this, as it really is doing nothing
// if (!session_is_registered('username'))
// {
$msga = "You are now logged out ! Please come back soon!";
echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>";
include '../index.php';
exit();
// }
}
else
{
// Include a file
include 'headermem.php';
// Echo something out, in white
echo '<div style="text-align: center; color:#fff;">Are you sure you want to logout?<br />';
echo '<a href="logout.php?logmeout=true">Yes</a> | <a href="javascript:history.back();">No</a></div>';
include 'footermem.php';
}
?>
It throws an error? I don't think I've ever had that throw an error. Interesting. Everah's way is probably better anyway. If you are using an xhtml page and run it through the xhtml validator it will throw up if you use font. <div>, <span>, and css are the new way of doing things.