-
1. Re: Having problem with header(location)
MurraySummers Oct 27, 2011 8:04 AM (in response to TCarp)So portal is properly setting the variable, and redirecting to gallery, right?
And if you delete the cookie and then browse directly to gallery, what is the message that you get?
-
2. Re: Having problem with header(location)
TCarp Oct 27, 2011 9:53 AM (in response to MurraySummers)No, regardless of which page I start (portal or gallery) I get the same error.
I cleared cookies and ran the tests again. No change.
The header(location) has sorta worked in the past. It was before I added the php logic to check the agreement. I could actually get it to redirect but had issues with styles seeming to be "lost" (i.e. go no css formatting).
I pulled all the php except the header in both portal and gallery and still got the error.
The message is:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.
I do not have cookies disabled.
Rebooted and tried again. Same error.
-
3. Re: Having problem with header(location)
MurraySummers Oct 27, 2011 11:24 AM (in response to TCarp)D'oh.
OK - change portal to this -
<?php
if ($_POST)
$_SESSION["agree"] = "Yes";
header( 'Location: http://www.example.com/myweb/gallery.php'' );
?>
and make a similar change to gallery. The location destination must be a fully qualified URL.
-
4. Re: Having problem with header(location)
TCarp Oct 27, 2011 3:34 PM (in response to MurraySummers)No difference. I am using a test server so used http://localhost...../gallery.php and /portal/php
As I mentioned in a previous post, I did get the redirect to work at one time. The difference was, at that time, there was no header in portal.php (i.e.gallery had the header but portal did not).
I took the header out of portal, browsed to gallery and the redirect worked. Similarly, if I left header in portal but took it out of gallery, browsing to portal successfully redirected to gallery.
I wonder if its because there is a header in both. I hadn't run across a warning about that while reading about heading. I did see the warning about not having any text sent to the browser before the header so, in both portal and gallery the header is before any html including DOCTYPE.
I wonder if redirect is intended to be used in this way. Most of the writing used examples of redirecting from pages that were no longer in use.
-
5. Re: Having problem with header(location)
TCarp Oct 27, 2011 7:48 PM (in response to MurraySummers)Just a follow up
I'm getting advice on another forum to use javascript triggered by the form on the portal page. I know less about javascript than I do about php so another learning journey.
I understand the "get" form would have the action pointing to possibly the gallery page to process the submit. I don't know what the script would look like but wonder if that's a solid approach for my particular need?
-
6. Re: Having problem with header(location)
MurraySummers Oct 28, 2011 5:40 AM (in response to TCarp)No difference. I am using a test server so used http://localhost...../gallery.php and /portal/php
You would have to remember to change this when you upload the pages. I believe if you would keep those links fully qualified (as I showed) and test the pages when actually uploaded you would find that they work. The code is right as far as I can tell.
There is nothing arcane or mysterious about doing this kind of redirection EXCEPT that page execution can continue after the redirection until you get to the end of the PHP block - for this reason, it's a good idea to follow the header command with an exit(); line, e.g.,
header("Location: http://www.example.com/foo.php");
exit();
-
7. Re: Having problem with header(location)
TCarp Oct 28, 2011 7:59 AM (in response to MurraySummers)Sorry, no merit badge yet. Results even after clearing cache, cookies, history, etc.
I get this in gallery (first user stop)
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_gallery.php:3) in /home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_gallery.php on line 5
Message repeats for cache limiter (Cannot send cache limiter)
Third message says cannot modify header information.
This is the current code:
Gallery
<?php
session_start();
if (!isset($_SESSION["agree"]))
header( "location: http://www.mydomain.org/portal.php" );
exit();
?>
Portal
<?php
if ($_POST)
$_SESSION["agree"] = "Yes";
header( "location: http://www.mydomain.org/gallery.php" );
exit();
?>
Form code in Portal
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type='submit' name='submit' value='I Agree' class='button'>
</form>
-
8. Re: Having problem with header(location)
MurraySummers Oct 28, 2011 8:02 AM (in response to TCarp)But that's a totally different error. It means you have already written something to the page prior to encountering the header() command. Can you paste your entire PHP region on these pages or is what you've pasted already it? The error is pointing to line 5....
-
9. Re: Having problem with header(location)
TCarp Oct 28, 2011 9:27 AM (in response to MurraySummers)I was forcing a connection to a db before the header command.
Moved it to after and am now getting the old redirect failure message from gallery.
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.
Gallery
<?php
session_start();
if (!isset($_SESSION["agree"]))
{ header( "location: http://www.mydomain.org/portal.php" );
exit(); }
?>
Portal
<?php
if ($_POST)
$_SESSION["agree"] = "Yes";
header("'location: http://www.mydomain.org/gallery.php" );
?>
-
10. Re: Having problem with header(location)
MurraySummers Oct 28, 2011 11:18 AM (in response to TCarp){ header( "location: http://www.mydomain.org/portal.php" );
--------------^
I've always seen that keyword given with an uppercase "L", i.e., "Location: " - try that.
header("'location: http://www.mydomain.org/gallery.php" );
-----------^
Ditto, and it looks like you have a double AND single quote there.
-
11. Re: Having problem with header(location)
TCarp Oct 30, 2011 9:43 AM (in response to MurraySummers)gallery.php
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.myspatialhome.org/ATL_counter_portal_header.php" ); }
?>
portal.php
<?php
if ($_POST)
$_SESSION["agree"] = "iagree";
header( "Location: http://www.myspatialhome.org/ATL_counter_gallery_header.php" );
?>
Form in portal
<form method='post' id='iagree'>
<input name='agree' value='I Agree' type='button'>
</form>
Getting same error.
Clear cache and cookies often.
-
12. Re: Having problem with header(location)
MurraySummers Oct 30, 2011 12:58 PM (in response to TCarp)http://www.gws-sandbox.com/test-gallery2.php
(note the original redirection)
GALLERY
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.gws-sandbox.com/test-portal2.php" ); }
?>
PORTAL
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.gws-sandbox.com/test-gallery2.php" );
}
?>
-
13. Re: Having problem with header(location)
TCarp Nov 2, 2011 9:13 AM (in response to MurraySummers)Sorry, although progress, can't get back from portal (i.e. Gallery sends to portal; I Agree button doesn't send back to gallery). Is there a problem in the way I've coded the form?
(I'll post separately with an alternative I'd like you to look at.)
GALLERY
<?php
if (!isset($_SESSION)) session_start();
if (!isset($_SESSION["agree"]))
{
header( "Location: http://www.mydomain.org/portal.php" );
} ?>
<?php
PORTAL
<?php
if (!isset($_SESSION)) session_start();
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree")
{
$_SESSION["agree"] = "iagree";
header( "Location: http://www.mydomain.org/gallery.php" );
}
?>
PORTAL FORM
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" id="iagree" name="form1">
<input name="agree" value="I Agree" type="button">
</form>
-
14. Re: Having problem with header(location)
TCarp Nov 2, 2011 9:25 AM (in response to MurraySummers)In the current design, portal processes the POST form. If the button has been pressed, the test results in a header.
Would it work to have the Form action point to gallery with the SESSION variable set before the button is pressed? In gallery I don't care how I got there so all I have to do is check the SESSION variable. If I want to tighten it up, I could add the POST test to gallery that was being done in portal.
If this is a worthy technique, which would you prefer to use? One with 2 header locations or one with a header location and a post action?
GALLERY
<?php
if (!isset($_SESSION)) session_start();
if (!isset($_SESSION["agree"]))
{
header( "Location: http://www.mydomain.org/portal.php" );
} ?>
<?php
PORTAL
<?php
if (!isset($_SESSION)) session_start();
$_SESSION["agree"] = "iagree"; // Pulled the POST check
}
?>
PORTAL FORM
<form action="http://www.mydomain.org/gallery.php" method="post" id="iagree" name="form1"> // Different action
<input name="agree" value="I Agree" type="button">
</form>
-
15. Re: Having problem with header(location)
MurraySummers Nov 2, 2011 9:39 AM (in response to TCarp)In Gallery, change this -
header( "Location: http://www.mydomain.org/portal.php" );
} ?>
to this -
header( "Location: http://www.mydomain.org/portal.php" );
exit();
} ?>
In Portal, change this -
<?php
if (!isset($_SESSION)) session_start();
$_SESSION["agree"] = "iagree"; // Pulled the POST check
}
?>
to this -
<?php
if (!isset($_SESSION)) session_start();
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") // Why did you pull this?
{
$_SESSION["agree"] = "iagree";
header( "Location: http://www.mydomain.org/gallery.php" );
exit();
}
?>
You want the test in both pages otherwise, I could browse directly to gallery without going through portal.
-
16. Re: Having problem with header(location)
MurraySummers Nov 2, 2011 9:41 AM (in response to MurraySummers)And at the link I posted earlier, browsing directly to gallery first relocates me to portal. Clicking agree takes me to gallery. You say it doesn't take you there?
Also, are you continuing to get the errors you were mentioned earlier?
-
17. Re: Having problem with header(location)
TCarp Nov 5, 2011 7:33 AM (in response to MurraySummers)Murray *ACP* wrote:
And at the link I posted earlier, browsing directly to gallery first relocates me to portal. Clicking agree takes me to gallery. You say it doesn't take you there?
Also, are you continuing to get the errors you were mentioned earlier?
Testing from gallery or portal gets me to portal. Pressing I AGREE in portal does nothing (i.e. doesn't send to gallery). The other errors (header warnings, etc.) appear to be gone. I've turned to testing on the remote server.
Current code:
gallery
<?php
if (!isset($_SESSION)) session_start();
if (!isset($_SESSION["agree"]))
{
header( "Location: http://www.mydomain.org/portal.php" );
exit(); // Added
} ?>
<?php
portal
<?php
if (!isset($_SESSION)) session_start();
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") // Added back. I see the hole you mentioned
{
$_SESSION["agree"] = "iagree";
header( "Location: http://www.mydomain.org/gallery.php" );
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" id="iagree" name="form1">
<input name="agree" value="I Agree" type="button">
</form>
Version 2
I've been testing a second version (to eliminate one of the header statements).
The key differences:
The form action points to gallery instead of to portal (PHP SELF); portal only check that a SESSION has been started, and gallery checks all three conditions (array key, $_Post value and $_SESSION set). If any are false, its off to portal.
gallery
<?php
if (!isset($_SESSION)) session_start();
if (!(array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree" && isset($_SESSION['iagree']))) {
header( "Location: http://www.mydomain.org/portal.php" );
exit(); // Added
} ?>
<?php
Portal is changed to return to gallery via the form action instead of via header
<?php
if (!isset($_SESSION)) session_start();
$_SESSION["agree"] = "iagree";
?>
<form action="http://www.mydomain.org/gallery.php" method="post" id="iagree" name="form1">
<input name="agree" value="I Agree" type="button">
</form>
Is there general wisdom about whether to have portal check and then send control to gallery (two header statements) or to have gallery do all the checking (one header statement)?
[EDIT]
One difference between your approach and mine is (I think) you have 3 files: gallery, portal, and the one with the I AGREE button. I include the I AGREE in portal. Issue?
Also, I may have a more basic issue just getting the form action to get back to gallery.
-
18. Re: Having problem with header(location)
MurraySummers Nov 5, 2011 8:17 AM (in response to TCarp)One difference between your approach and mine is (I think) you have 3 files: gallery, portal, and the one with the I AGREE button.
Nope. Only two files - portal and gallery.
PORTAL -
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.gws-sandbox.com/test-gallery2.php" );
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input type="submit" name="agree" value="I Agree">
</form>
</body>
</html>
GALLERY -
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.gws-sandbox.com/test-gallery2.php" );
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input type="submit" name="agree" value="I Agree">
</form>
</body>
</html>
In your PORTAL page, you have this -
<?php
if (!isset($_SESSION)) session_start();
$_SESSION["agree"] = "iagree";
?>
Looks like that is setting the session variable whether you click it or not. Seems bad to me.
I'm troubled by the fact that what is working for me is not working for you. You are browsing to and using MY posted links right?
-
19. Re: Having problem with header(location)
TCarp Nov 22, 2011 8:20 AM (in response to MurraySummers)In your PORTAL page, you have this -
<?php
if (!isset($_SESSION)) session_start();
$_SESSION["agree"] = "iagree";
?>
Looks like that is setting the session variable whether you click it or not. Seems bad to me.
I'm troubled by the fact that what is working for me is not working for you. You are browsing to and using MY posted links right?
You're right that it isn't solid code. It was part of a design before adding the specific check of the form data. In other words, when entering portal the assumption is the only way to leave was through the form sending things to gallery. It's a better design to add specific checks for the form data so new versions of the code don't do things this way.
Just starting to test your code. I can get it to work if I browse to your file names. I'm getting an error when I replace the location data with my filenames. I'll post again after I spend some time testing.
-
20. Re: Having problem with header(location)
TCarp Nov 22, 2011 8:24 AM (in response to MurraySummers)Did you mean to post that both gallery and portal had the same php/html?
-
21. Re: Having problem with header(location)
MurraySummers Nov 22, 2011 10:11 AM (in response to TCarp)Probably not!
-
22. Re: Having problem with header(location)
TCarp Nov 24, 2011 7:50 AM (in response to MurraySummers)Sorry for having this take so long. I'm baffled.
I browsed to your pages and things seemed to work (no error). When I test my version I get errors. If I browse to gallery I get "XXXXX" (an <h1></h1> in gallery) displayed but are not sent to portal (i.e. no I Agree button). If I browse to portal and select the I Agree button I get this:
Warning: Cannot modify header information - headers already sent by (output started at /home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_portal_murray.php:5) in /home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_portal_murray.php on line 8
PORTAL
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.myspatialhome.org/ATL_counter_gallery_murray.php" );
exit();
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input type="submit" name="agree" value="I Agree">
</form>
</body>
</html>
GALLERY
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.myspatialhome.org/ATL_counter_portal_murray.php" );
exit(); } NOTE: I've tested with and without this exit. Same results.
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<h1>XXXXX</h1>
</body>
</html>
-
23. Re: Having problem with header(location)
MurraySummers Nov 25, 2011 9:00 AM (in response to TCarp){ header( "Location: http://www.myspatialhome.org/ATL_counter_portal_murray.php" );
exit(); } NOTE: I've tested with and without this exit. Same results.
?>
<!doctype html>
Yes, that's correct. The reason you get the same results is that it's the last command in the last PHP block. If there were additional PHP code below, that code would be executed BEFORE the redirection occurs, something that is sure to give you a headache, if not a problem. It's a good habit to always include that exit as a safeguard against this oversight, just the same as it's a good practice to get into the habit of always ending your CSS styles with a semicolon (e.g., color:red;).
-
24. Re: Having problem with header(location)
MurraySummers Nov 25, 2011 9:02 AM (in response to MurraySummers)Oops - wrong button. Continuing,
If I browse to portal and select the I Agree button I get this:
Warning: Cannot modify header information - headers already sent by (output started at /home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_portal_murray.p hp:5) in/home/content/T/S/B/TSBusiness/html/atlas/ATL_counter_portal_murray.ph p on line 8
This error is coming from this code -
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
The whitespace between the two blocks is a nasty mistake! Change that code to this -
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
and the error will go away, and the redirection will then work for both files.
-
25. Re: Having problem with header(location)
TCarp Dec 3, 2011 7:02 AM (in response to MurraySummers)Wow!! This is a big "a ha" for me.
What happened? A blank line between two php blocks is enough to cause problems!
Is it because the blocks come before any html? If they were after <html> I'd expect them to be treated as html blank lines and ignored.
I assume I could also have eliminated the problem if I combined the two php blocks (since they follow each other).
I would appreciate some learning here so any explanation would be very much appreciated.
Murray, thanks again for being so attentive to these forums. I've gotten valuable advice from you on a number of occasions in the past. Once again....
Tom
-
26. Re: Having problem with header(location)
TCarp Dec 3, 2011 7:31 AM (in response to MurraySummers)Oops, spoke too soon.
The previous error went away but the process isn't working yet.
Gallery sends to portal and the I Agree in portal appears to send back to gallery (shows in url display) but nothing is displayed.
I'll have to do some more testing....
Tom
Gallery
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.myspatialhome.org/ATL_counter_portal.php" );
}
exit();
?>
Portal
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.myspatialhome.org/ATL_counter_gallery.php" );
exit();
}
?>
Form in Portal
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input name='agree' value='I Agree' type='submit'>
</form>
-
27. Re: Having problem with header(location)
MurraySummers Dec 3, 2011 12:31 PM (in response to TCarp)What happened? A blank line between two php blocks is enough to cause problems!
Yes - because it's not part of a PHP block, the browser sends it to the page - that prevents further PHP "header()" commands from working, and they throw an error that output has already started, as you have seen.
Gallery sends to portal and the I Agree in portal appears to send back to gallery (shows in url display) but nothing is displayed.
Is this the code on your gallery page?
<body>
<h1>XXXXX</h1>
</body>
</html>
If you have in fact gone back to the gallery page, you should certainly see that.
-
28. Re: Having problem with header(location)
TCarp Dec 4, 2011 7:19 AM (in response to MurraySummers)Gallery sends to portal and the I Agree in portal appears to send back to gallery (shows in url display) but nothing is displayed.
Is this the code on your gallery page?
<body>
<h1>XXXXX</h1>
</body>
</html>
If you have in fact gone back to the gallery page, you should certainly see that.
I should have mentioned that the test php files (...gallery_murray and ...portal_murray) appear to work fine. What I did next was to copy the php from those two files to copies of the production versions (with appropriate changes to the header file names). Those new test php files are ...gallery_header and ...portal_header.
http://www.myspatialhome.org/ATL_counter_gallery_header.php
Gallery gets to portal and I Agree gets to gallery but nothing is displayed. Looking at the source there's nothing generated. I'm assuming this is not a problem with the header php you helped with but something happening later in the gallery php file.
This is the gallery code down to the doctype. Minus the php at the beginning that does the header (like in the gallery_murray file), the code works.
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.myspatialhome.org/ATL_counter_portal_header.php" );
}
exit();
?>
<?php
require_once('Connections/atlas.php'); // NOTE: Also may require change in href for detail
if (!function_exists("GetSQLValueString"))
{
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6)
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType)
{
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"]; // Get the current URL for hrefs
// New group code
mysql_select_db($database_atlas, $atlas);
$groups = mysql_query("SELECT * FROM tblMapGroups ORDER BY DispSeq ASC"); // Get the group records
$row_groups = mysql_fetch_assoc($groups);
if (!$_GET)
$selectGroup = $row_groups['MapGroupID']; // First time through; set initial default group
else $selectGroup = $_GET['groupselect']; // Otherwise use GET to retrieve the submit button chosen
mysql_data_seek($groups, 0); // Reset to first record for Form loop
// End new group code
// Select map records
$query_maps1 = "SELECT * FROM tblMaps";
$query_maps2 = "ORDER BY tblMaps.MapGroup, tblMaps.Area, tblMaps.Community, tblMaps.DispSeq ";
$query_maps = sprintf("%s WHERE MapGroup ='%s' %s", $query_maps1, $selectGroup, $query_maps2);
$maps = mysql_query($query_maps, $atlas) or die(mysql_error());
$row_maps = mysql_fetch_assoc($maps);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
29. Re: Having problem with header(location)
MurraySummers Dec 5, 2011 7:26 AM (in response to TCarp)A blank page means that there is an error on the page. Change this -
<?php
if (!isset($_SESSION)) session_start();
?>
to this -
<?php
if (!isset($_SESSION)) session_start();
ini_set('display_errors', 1);
?>
And let's see what gets thrown on returning to that page.
-
30. Re: Having problem with header(location)
TCarp Dec 5, 2011 6:26 PM (in response to MurraySummers)Sorry, no change
I added the code to gallery first and tested, and then added it also to portal and tested.
Nothing is displayed and display source shows no html. The URL shows gallery so we're getting back to that page.
I'll run a test tomorrow deleting all the php between the code you helped with and the doctype. It's there to deal with wierd characters in a MySQL file.
I'll post back after the test
-
31. Re: Having problem with header(location)
TCarp Dec 6, 2011 7:08 AM (in response to MurraySummers)I ran a couple test this morning to see if I could isolate the problem a little.
First, I removed all php between the code the does the header stuff and the doctype (i.e. all that remained was the gallery to portal and I Agree check code). This code was generated as part of master/detail in DW and appears to check for special characters in a mySQL record.
No change (i.e. blank page displayed and no source code listed when displayed).
I then took ALL the php before the doctype out (the code you're helping with and the mySQL code). I get a page displayed albiet with mySQL errors (the connection was one of the code lines removed).
I'm not sure I fully understand what the results mean. It appears the header code in a simple test page (murray with gallery displaying <h1>XXXXX</h1>) works but, the same header code in the production page (with more complex html along with mySQL work) does not. It also appears the additional php code on the production page before the doctype is not the culpret.
This would mean there's something about the html and the header code that's incompatible.
Keep in mind the html is exactly whats in the production version of gallery that's uploaded to the site. I merely copied that page (in DW) and added the header php code.
I'll keep looking but, for now, it's beyond my skills.
Tom
-
32. Re: Having problem with header(location)
TCarp Dec 12, 2011 9:55 AM (in response to MurraySummers)I'm sorry to say it looks like I've taken a step backwards. I now can't get the basic (murray) test to work.
I can get from gallery to portal and I Agree button in portal displays the gallery url in the browser but nothing is displayed on the page. This is the test that would have displayed <h1>XXXXX</h1>
Gallery:
<?php
if (!isset($_SESSION)) session_start();
ini_set('display_errors', 1);
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.myspatialhome.org/ATL_counter_portal_murray.php" );
}
exit();
?>
Portal:
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.myspatialhome.org/ATL_counter_gallery_murray.php" );
exit();
}
?>
Portal Form:
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input type="submit" name="agree" value="I Agree">
</form>
Sorry this is draging on so long.
Tom
-
33. Re: Having problem with header(location)
TCarp Dec 13, 2011 8:23 AM (in response to MurraySummers)Looks like your version isn't working either
http://www.gws-sandbox.com/test-gallery2.php
Gets to portal but shows an untitled blank page with no comment on I Agree
-
34. Re: Having problem with header(location)
MurraySummers Dec 15, 2011 5:16 AM (in response to TCarp)That's only because there is no content to display on that page. Silly me. Try it now.
-
35. Re: Having problem with header(location)
TCarp Dec 15, 2011 8:00 AM (in response to MurraySummers)Now would you please copy/paste the code here. It should include gallery and two parts of portal (the header work and the form). And then I'll do some "one step at a time" testing until I get all the current code integrated.
Thanks
Tom
-
36. Re: Having problem with header(location)
MurraySummers Dec 15, 2011 8:43 AM (in response to TCarp)PORTAL
------------
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (array_key_exists('agree',$_POST) && $_POST['agree'] == "I Agree") {
$_SESSION["agree"] = "iagree";
header( "Location: http://www.gws-sandbox.com/test-gallery2.php" );
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method='post' name="form1" id='iagree' action="<?php echo $_server['PHP_SELF']; ?>">
<input type="submit" name="agree" value="I Agree">
</form>
</body>
</html>
GALLERY
--------------
<?php
if (!isset($_SESSION)) session_start();
?>
<?php
if (!isset($_SESSION["agree"]))
{ header( "Location: http://www.gws-sandbox.com/test-portal2.php" ); }
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test Gallery 2 Page</title>
</head>
<body>
<p>Nyuck, nyuck</p>
</body>
</html>
-
37. Re: Having problem with header(location)
TCarp Dec 16, 2011 8:58 AM (in response to MurraySummers)Y-RIKA!!! It works!
Not sure what was wrong. Was more careful during copy/paste and the changes to the header urls to integrate in existing code.
Thanks
Tom
-
38. Re: Having problem with header(location)
MurraySummers Dec 18, 2011 5:53 AM (in response to TCarp)Good luck! That was certainly a long drink!


