I am trying PHP4.23 and PHP4.3. They worked fine with GET only. ALL POST and COOKIE are empty??? They are basic functions of Web development. I used PHP.INI-RECOMMENDED and turn on the OUTPUT_BUFFERING=4096 only. Here is my test code:

<html>
<head>
<title>TEST</title>

</head>
<body>
<?
echo "<BR> REQUEST:";
print_r($REQUEST);
print_r($HTTP_REQUEST_VARS);
echo "<BR> POST:";
print_r($
POST);
print_r($HTTP_POST_VARS);
echo "<BR> GET:";
print_r($GET);
print_r($HTTP_GET_VARS);
echo "<BR> COOKIE:";
print_r($
COOKIE);
print_r($HTTP_COOKIE_VARS);
echo "<BR> FILES:";
print_r($_FILES);
print_r($HTTP_FILES_VARS);
?>
<form action="test.php?hello=hello" method=post>
<input type=text id=ftext value=123></input>
<br><br>
<input type=submit></input>
<?
$start=time();
setcookie("start",$start,time()+600,",","",0);
?>
</form>
</body>
</html>

But the result always EMPTY???:
REQUEST:Array ( [hello] => hello )
POST:Array ( ) Array ( )
GET:Array ( [hello] => hello ) Array ( [hello] => hello )
COOKIE:Array ( ) Array ( )
FILES:Array ( )

WHO, PHP Experts, please help me! Thanks.

(I have checked internet and tried many different ways to do it for several days. Reinstall PHP serveral times. Used both IIS and Apache2. All were same results ... (EMPTY ARRAY!!!))
😕

    The way you are "posting" to that script isn't a post you are sending get information to it. You have to put an input box in the form with a name and value and just have the action equal test.php no question mark after it. Also since you are using a new version of PHP forget about the HTTP arrays and just use the $ arrays it will save you a bit of typing. Also your setcookie stuff must be done before any data is sent to the user so put it before the <html> tag, all header information must be done before anything else is sent.

      <input type=text name=ftext value=123></input>

      😉

        Thanks all, I got the POST working now. But not the cookie yet?
        Here is my code for testing cookie.

        <?
        setcookie("start",$start);
        setcookie("count",$count);
        $start=time();
        if(isset($count)) $count++ ;else $count=1;
        ?>
        <html>
        <head>
        <title>TEST</title>

        </head>
        <body>
        <?
        echo "<BR> REQUEST:";
        print_r($REQUEST);
        echo "<BR> COOKIE:";
        print_r($
        COOKIE);
        echo "<BR> POST:";
        print_r($_COOKIE);
        ?>
        <form action="test.php" method=get>
        <input type="text" id="ftext" name="ftext" value="123"></input>
        <br><br>
        <input type=submit></input>
        </form>
        <? echo "Start:$start <br>Count:$count"; ?>
        </body>
        </html>

        The result is that cookie $count always 1??? What setting in PHP.INI did I miss???

        😕

          Forgive me if I offend, that is not my intent.

          You set a cookie with the value $count, which has not yet
          been assigned.

          Then, you increment this null value, or else assign it a value of 1.

          Finally, you complain that the value of $count is always equal to 1.

          I would not be surprised at all by such a result.

            Thanks for your advise. I got it function now.

            I make the code like that because I mis-understood setCookie is registration-like function. Once I register a cookie, it will become view as a variable. Any change in the variable will reflect in the cookie as well. Now, I understand that it works like the set cookie function of other web scripts.

            Thanks for your kind reply.🙂

              Write a Reply...