Jump to content

[SOLVED] Includes


Clinton

Recommended Posts

Here's the complete code:

 

<?
session_start();
if(!isset($_REQUEST['logmeout'])){
echo "<center>Are you sure you want to logout?</center><br />";
echo "<center><a href=logout.php?logmeout=true>Yes</a> |
<a href=javascript:history.back()>No</a>";
} else {
session_destroy();
if(!session_is_registered('first')){
echo "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";
echo "<center><strong>Login:</strong></center><br />";
include './index.php';
}
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524246
Share on other sites

Sorry, I believe you already said that. :-|

 

Here's the code. But it keeps taking me back, looping, to the Yes / No part. It doesn't follow through.

 


<?
session_start();
if(!isset($_POST['logmeout'])){
echo "<center>Are you sure you want to logout?</center><br />";
echo "<center><a href=logout.php?logmeout=true>Yes</a> |
<a href=javascript:history.back()>No</a>";
} else {
session_destroy();
if(!session_is_registered('first')){
echo "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";
echo "<center><strong>Login:</strong></center><br />";
header("Location: ./index.php");
}
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524256
Share on other sites

Whenevery you send a new header, or move to a new page, you cannot have any echos or anything before the header.  The best way to resolve this is assign session variables those values and echo those on the script you want, in the place you want.  It will not hurt if the variables are empty.

 

<?php
session_start();
if(!isset($_POST['logmeout'])){
echo "<center>Are you sure you want to logout?</center><br />";
echo "<center><a href=logout.php?logmeout=true>Yes</a> |
<a href=javascript:history.back()>No</a>";
} else {
session_destroy();
if(!session_is_registered('first')){

// I changed the echos to session variables
// *Note you will have to echo these values on the index.php script
$_SESSION['varname'] = "<center><font color=red><strong>You are now logged out!</strong></font></center><br />";
$_SESSIOB['varname2'] = "<center><strong>Login:</strong></center><br />";
header("Location: ./index.php");
}
}
?> 

 

 

More info on header errors: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

Link to comment
https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524545
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.