Clinton Posted April 22, 2008 Share Posted April 22, 2008 This code is located in a test/required/blah.php When it finishes reading the script how do I tell it to go to the login page at test/index.php? include './index.php'; Link to comment https://forums.phpfreaks.com/topic/102385-solved-includes/ Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 What are you trying to do? Include code: <?php include("folder/folder/include.inc"); ?> Change page in browser: <?php header("Location: location.php"); ?> Link to comment https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524243 Share on other sites More sharing options...
papaface Posted April 22, 2008 Share Posted April 22, 2008 header('Location: test/index.php'); Link to comment https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524244 Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 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 More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 1) DON'T USE REQUEST. =/ 2) header("Location: ./index.php"); Link to comment https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524250 Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 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 More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 Well, I was using POST instead of GET. That was that problem. But now I am getting, when logging out an error that says: Warning: Cannot modify header information - headers already sent Link to comment https://forums.phpfreaks.com/topic/102385-solved-includes/#findComment-524258 Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.