PHP Can't read from passed headers
I have code like this
On one page say test.htm I have this: <a href="test1.php?id=4">Link</a> On test1.php I have <? if( $id == 4 ) { print "This works"; } else { print "This does not work"; } ?> It will always say "This does not work" I am running PHP 4.3.4, Apache 2.048, Linux Debian 2.2.24. Thanks |
I figured out that the headers are not being sent from page to page by using if(headers_sent()) {pint "blah" } ... If anyone knows if the fix is in apache or in PHP? Or something else....
Thanks |
OK now I am confused if I run this code:
<?php if(headers_sent()) { if($id == 4) { print "YES! It is Equal to 4"; } else { print "Not Working!"; print "<a href=\"test1.php?id=4\">Link</a>"; } } else { print "not working"; } $headers = apache_request_headers(); foreach ($headers as $header => $value) { echo "$header: $value <br />\n"; } I get this output: not workingAccept: */* Referer: http://68.213.252.148/test2.htm Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Host: 68.xxx.xxxx.xxx |
OK I am completely OFF the Headers are sent.
|
Newer versions of php have 'Register_Globals=Off" by default in your php.ini. Turning that on represents certain security risks so to access $id use "$_GET["id"]'. The following code should work as you expect.
Code:
<? if( $_GET["id"] == 4 ) |
Got it working thanks.
|
All times are GMT -5. The time now is 09:35 AM. |