LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-23-2004, 05:37 PM   #1
uuplunkeruu
LQ Newbie
 
Registered: Jan 2003
Location: Miami, Florida
Distribution: Debian, Fbsd, Obsd
Posts: 10

Rep: Reputation: 0
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
 
Old 03-23-2004, 05:57 PM   #2
uuplunkeruu
LQ Newbie
 
Registered: Jan 2003
Location: Miami, Florida
Distribution: Debian, Fbsd, Obsd
Posts: 10

Original Poster
Rep: Reputation: 0
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
 
Old 03-23-2004, 06:18 PM   #3
uuplunkeruu
LQ Newbie
 
Registered: Jan 2003
Location: Miami, Florida
Distribution: Debian, Fbsd, Obsd
Posts: 10

Original Poster
Rep: Reputation: 0
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
 
Old 03-23-2004, 06:22 PM   #4
uuplunkeruu
LQ Newbie
 
Registered: Jan 2003
Location: Miami, Florida
Distribution: Debian, Fbsd, Obsd
Posts: 10

Original Poster
Rep: Reputation: 0
OK I am completely OFF the Headers are sent.
 
Old 03-23-2004, 11:53 PM   #5
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
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 )
{ print "This works"; }
else
{ print "This does not work"; }
?>
 
Old 03-24-2004, 04:38 PM   #6
uuplunkeruu
LQ Newbie
 
Registered: Jan 2003
Location: Miami, Florida
Distribution: Debian, Fbsd, Obsd
Posts: 10

Original Poster
Rep: Reputation: 0
Got it working thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php5 apache2 mysql4 don't work, php does not seem to read php.ini atom Linux - Software 5 03-24-2005 11:05 AM
php not taking arguments when passed through URLs BrianK Linux - Software 2 03-29-2004 11:38 AM
Can parameters passed to a php be hide ? cjagdish69 Linux - Software 1 11-11-2003 07:09 AM
read mail headers from command line plisken Linux - General 5 04-13-2003 01:53 PM
php variables not being passed on tpat Linux - Software 1 01-11-2003 03:11 PM


All times are GMT -5. The time now is 07:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration