problems with POST

This is a discussion on problems with POST within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-27-2005
moriman
 
Posts: n/a
Default problems with POST

Hi,

The script below *used* to work. I have only just set up a
server, PHP etc again on my Win98 system and now it doesn't?

On first loading this page, you would have

$p =

and the button image below it.
On clicking the button the same page would reload but pass the hidden values
(r=w & p=f)
so that the first line of the page would then have

$p = f

This no longer works???

<?php
echo "<html><body>";
echo "\$p = $p<br><br>"; //###
$str = <<<HTM
<head>
</head>
<body>
<form action="" method="post">
<input type="hidden" name="r" value="w">
<input type="hidden" name="p" value="f">
<input type="image" src="http://home/images/faq-up.gif" border="0"
height="22" width="77">
</form>
</body>
</html>
HTM;
echo $str;
?>


on printing the $_ENV variables along with the the above script I find the
following :

QUERY_METHOD POST
REQUEST_METHOD POST
FORM_P f
FORM_R w

Is there something I haven't enabled in my
setup of PHP that is stopping this from working now?

Or has something changed with PHP, so that I have to do this another way?

many thanks

mori



Reply With Quote
  #2 (permalink)  
Old 11-27-2005
Gordon Burditt
 
Posts: n/a
Default Re: problems with POST

>The script below *used* to work. I have only just set up a
>server, PHP etc again on my Win98 system and now it doesn't?


A variable passed from HTML by the POST method is $_POST['r'] or
$_POST['p'], *not* $r or $p. (Also see $_GET for variables
passed by the GET method). Fix your script. Do not turn
on "register_globals".

Gordon L. Burditt


>
>On first loading this page, you would have
>
>$p =
>
>and the button image below it.
>On clicking the button the same page would reload but pass the hidden values
>(r=w & p=f)
>so that the first line of the page would then have
>
>$p = f
>
>This no longer works???
>
><?php
>echo "<html><body>";
>echo "\$p = $p<br><br>"; //###
>$str = <<<HTM
><head>
></head>
><body>
><form action="" method="post">
> <input type="hidden" name="r" value="w">
> <input type="hidden" name="p" value="f">
> <input type="image" src="http://home/images/faq-up.gif" border="0"
>height="22" width="77">
></form>
></body>
></html>
>HTM;
>echo $str;
>?>
>
>
>on printing the $_ENV variables along with the the above script I find the
>following :
>
>QUERY_METHOD POST
>REQUEST_METHOD POST
>FORM_P f
>FORM_R w
>
>Is there something I haven't enabled in my
>setup of PHP that is stopping this from working now?
>
>Or has something changed with PHP, so that I have to do this another way?
>
>many thanks
>
>mori
>
>
>



Reply With Quote
  #3 (permalink)  
Old 11-27-2005
moriman
 
Posts: n/a
Default Re: problems with POST

wow, thx for the *very* quick reply ;-)

tried changing the
echo "\$p = $p<br><br>";

to

echo "\$p = " . $_POST['p'] . "<br><br>";

but still not working :(

mori

"Gordon Burditt" <gordonb.ari4j@burditt.org> wrote in message
news:11ok7r8qgjmg89a@corp.supernews.com...
> >The script below *used* to work. I have only just set up a
> >server, PHP etc again on my Win98 system and now it doesn't?

>
> A variable passed from HTML by the POST method is $_POST['r'] or
> $_POST['p'], *not* $r or $p. (Also see $_GET for variables
> passed by the GET method). Fix your script. Do not turn
> on "register_globals".
>
> Gordon L. Burditt
>
>
> >
> >On first loading this page, you would have
> >
> >$p =
> >
> >and the button image below it.
> >On clicking the button the same page would reload but pass the hidden

values
> >(r=w & p=f)
> >so that the first line of the page would then have
> >
> >$p = f
> >
> >This no longer works???
> >
> ><?php
> >echo "<html><body>";
> >echo "\$p = $p<br><br>"; //###
> >$str = <<<HTM
> ><head>
> ></head>
> ><body>
> ><form action="" method="post">
> > <input type="hidden" name="r" value="w">
> > <input type="hidden" name="p" value="f">
> > <input type="image" src="http://home/images/faq-up.gif" border="0"
> >height="22" width="77">
> ></form>
> ></body>
> ></html>
> >HTM;
> >echo $str;
> >?>
> >
> >
> >on printing the $_ENV variables along with the the above script I find

the
> >following :
> >
> >QUERY_METHOD POST
> >REQUEST_METHOD POST
> >FORM_P f
> >FORM_R w
> >
> >Is there something I haven't enabled in my
> >setup of PHP that is stopping this from working now?
> >
> >Or has something changed with PHP, so that I have to do this another way?
> >
> >many thanks
> >
> >mori
> >
> >
> >

>
>



Reply With Quote
  #4 (permalink)  
Old 11-27-2005
PeteY48
 
Posts: n/a
Default Re: problems with POST

Don't know much about PHP, but it does appear you are sending "<body>"
twice, once in line 2 and once in line 7. The one in line 2 should be
deleted so the "<head>" section of the page comes first. Or you need to
rearrange the order of your statements.

Reply With Quote
  #5 (permalink)  
Old 11-28-2005
moriman
 
Posts: n/a
Default Re: problems with POST


"PeteY48" <peteyoung1@gmail.com> wrote in message
news:1133128331.708828.94660@z14g2000cwz.googlegro ups.com...
> Don't know much about PHP, but it does appear you are sending "<body>"
> twice, once in line 2 and once in line 7. The one in line 2 should be
> deleted so the "<head>" section of the page comes first. Or you need to
> rearrange the order of your statements.
>


Yes, you are right about the double <head>, this was due to shortening the
script and missing this repeat.
However, this makes absolutely no difference to the operation of the script.


Reply With Quote
  #6 (permalink)  
Old 11-28-2005
Juliette
 
Posts: n/a
Default Re: problems with POST

moriman wrote:
> wow, thx for the *very* quick reply ;-)
>
> tried changing the
> echo "\$p = $p<br><br>";
>
> to
>
> echo "\$p = " . $_POST['p'] . "<br><br>";
>
> but still not working :(
>
> mori
>
> "Gordon Burditt" <gordonb.ari4j@burditt.org> wrote in message
> news:11ok7r8qgjmg89a@corp.supernews.com...
>
>>>The script below *used* to work. I have only just set up a
>>>server, PHP etc again on my Win98 system and now it doesn't?

>>
>>A variable passed from HTML by the POST method is $_POST['r'] or
>>$_POST['p'], *not* $r or $p. (Also see $_GET for variables
>>passed by the GET method). Fix your script. Do not turn
>>on "register_globals".
>>
>>Gordon L. Burditt
>>
>>
>>
>>>On first loading this page, you would have
>>>
>>>$p =
>>>
>>>and the button image below it.
>>>On clicking the button the same page would reload but pass the hidden

>
> values
>
>>>(r=w & p=f)
>>>so that the first line of the page would then have
>>>
>>>$p = f
>>>
>>>This no longer works???
>>>
>>><?php
>>>echo "<html><body>";
>>>echo "\$p = $p<br><br>"; //###
>>>$str = <<<HTM
>>><head>
>>></head>
>>><body>
>>><form action="" method="post">
>>> <input type="hidden" name="r" value="w">
>>> <input type="hidden" name="p" value="f">
>>> <input type="image" src="http://home/images/faq-up.gif" border="0"
>>>height="22" width="77">
>>></form>
>>></body>
>>></html>
>>>HTM;
>>>echo $str;
>>>?>
>>>
>>>
>>>on printing the $_ENV variables along with the the above script I find

>
> the
>
>>>following :
>>>
>>>QUERY_METHOD POST
>>>REQUEST_METHOD POST
>>>FORM_P f
>>>FORM_R w
>>>
>>>Is there something I haven't enabled in my
>>>setup of PHP that is stopping this from working now?
>>>
>>>Or has something changed with PHP, so that I have to do this another way?
>>>
>>>many thanks
>>>
>>>mori
>>>
>>>
>>>

>>
>>

>
>


Try:

echo "\$p = " . $HTTP_POST_VARS['p'] . "<br><br>";
Reply With Quote
  #7 (permalink)  
Old 11-28-2005
moriman
 
Posts: n/a
Default Re: problems with POST


"Juliette" <jrf_no_spam@jokeaday.net> wrote in message
news:438a9e1c$0$64688$dbd45001@news.wanadoo.nl...
> moriman wrote:
> > wow, thx for the *very* quick reply ;-)
> >
> > tried changing the
> > echo "\$p = $p<br><br>";
> >
> > to
> >
> > echo "\$p = " . $_POST['p'] . "<br><br>";
> >
> > but still not working :(
> >
> > mori
> >
> > "Gordon Burditt" <gordonb.ari4j@burditt.org> wrote in message
> > news:11ok7r8qgjmg89a@corp.supernews.com...
> >
> >>>The script below *used* to work. I have only just set up a
> >>>server, PHP etc again on my Win98 system and now it doesn't?
> >>
> >>A variable passed from HTML by the POST method is $_POST['r'] or
> >>$_POST['p'], *not* $r or $p. (Also see $_GET for variables
> >>passed by the GET method). Fix your script. Do not turn
> >>on "register_globals".
> >>
> >>Gordon L. Burditt
> >>
> >>
> >>
> >>>On first loading this page, you would have
> >>>
> >>>$p =
> >>>
> >>>and the button image below it.
> >>>On clicking the button the same page would reload but pass the hidden

> >
> > values
> >
> >>>(r=w & p=f)
> >>>so that the first line of the page would then have
> >>>
> >>>$p = f
> >>>
> >>>This no longer works???
> >>>
> >>><?php
> >>>echo "<html><body>";
> >>>echo "\$p = $p<br><br>"; //###
> >>>$str = <<<HTM
> >>><head>
> >>></head>
> >>><body>
> >>><form action="" method="post">
> >>> <input type="hidden" name="r" value="w">
> >>> <input type="hidden" name="p" value="f">
> >>> <input type="image" src="http://home/images/faq-up.gif" border="0"
> >>>height="22" width="77">
> >>></form>
> >>></body>
> >>></html>
> >>>HTM;
> >>>echo $str;
> >>>?>
> >>>
> >>>
> >>>on printing the $_ENV variables along with the the above script I find

> >
> > the
> >
> >>>following :
> >>>
> >>>QUERY_METHOD POST
> >>>REQUEST_METHOD POST
> >>>FORM_P f
> >>>FORM_R w
> >>>
> >>>Is there something I haven't enabled in my
> >>>setup of PHP that is stopping this from working now?
> >>>
> >>>Or has something changed with PHP, so that I have to do this another

way?
> >>>
> >>>many thanks
> >>>
> >>>mori
> >>>
> >>>
> >>>
> >>
> >>

> >
> >

>
> Try:
>
> echo "\$p = " . $HTTP_POST_VARS['p'] . "<br><br>";


nope, doesn't work either :(


Reply With Quote
  #8 (permalink)  
Old 11-28-2005
Wolfgang Forstmeier
 
Posts: n/a
Default Re: problems with POST



moriman wrote:
> "Juliette" <jrf_no_spam@jokeaday.net> wrote in message
> news:438a9e1c$0$64688$dbd45001@news.wanadoo.nl...
>> moriman wrote:
>>> wow, thx for the *very* quick reply ;-)
>>>
>>> tried changing the
>>> echo "\$p = $p<br><br>";
>>>
>>> to
>>>
>>> echo "\$p = " . $_POST['p'] . "<br><br>";
>>>
>>> but still not working :(
>>>
>>> mori
>>>
>>> "Gordon Burditt" <gordonb.ari4j@burditt.org> wrote in message
>>> news:11ok7r8qgjmg89a@corp.supernews.com...
>>>
>>>>> The script below *used* to work. I have only just set up a
>>>>> server, PHP etc again on my Win98 system and now it doesn't?
>>>> A variable passed from HTML by the POST method is $_POST['r'] or
>>>> $_POST['p'], *not* $r or $p. (Also see $_GET for variables
>>>> passed by the GET method). Fix your script. Do not turn
>>>> on "register_globals".
>>>>
>>>> Gordon L. Burditt
>>>>
>>>>
>>>>
>>>>> On first loading this page, you would have
>>>>>
>>>>> $p =
>>>>>
>>>>> and the button image below it.
>>>>> On clicking the button the same page would reload but pass the hidden
>>> values
>>>
>>>>> (r=w & p=f)
>>>>> so that the first line of the page would then have
>>>>>
>>>>> $p = f
>>>>>
>>>>> This no longer works???
>>>>>
>>>>> <?php
>>>>> echo "<html><body>";
>>>>> echo "\$p = $p<br><br>"; //###
>>>>> $str = <<<HTM
>>>>> <head>
>>>>> </head>
>>>>> <body>
>>>>> <form action="" method="post">
>>>>> <input type="hidden" name="r" value="w">
>>>>> <input type="hidden" name="p" value="f">
>>>>> <input type="image" src="http://home/images/faq-up.gif" border="0"
>>>>> height="22" width="77">
>>>>> </form>
>>>>> </body>
>>>>> </html>
>>>>> HTM;
>>>>> echo $str;
>>>>> ?>
>>>>>
>>>>>
>>>>> on printing the $_ENV variables along with the the above script I find
>>> the
>>>
>>>>> following :
>>>>>
>>>>> QUERY_METHOD POST
>>>>> REQUEST_METHOD POST
>>>>> FORM_P f
>>>>> FORM_R w
>>>>>
>>>>> Is there something I haven't enabled in my
>>>>> setup of PHP that is stopping this from working now?
>>>>>
>>>>> Or has something changed with PHP, so that I have to do this another

> way?
>>>>> many thanks
>>>>>
>>>>> mori
>>>>>
>>>>>
>>>>>
>>>>
>>>

>> Try:
>>
>> echo "\$p = " . $HTTP_POST_VARS['p'] . "<br><br>";

>
> nope, doesn't work either :(
>
>


This will work, you have to set up an submit button
(javascript or nativ html to send your form data)

If you would like to have an image you should prefer JavaScript.
If a simple HTML - Button is enougth try the simple Submit Button like
in my example.
Have Fun...

<?php
echo "<html>";
echo "\$p = ".$_POST['p']."<br><br>"; //###
$str = <<<HTM
<head>
</head>
<body>
<form action="" method="post">
<input type="hidden" name="r" value="w">
<input type="hidden" name="p" value="f">
<input type="submit">
</form>
</body>
</html>
HTM;
echo $str;
?>
Reply With Quote
  #9 (permalink)  
Old 11-28-2005
Jerry Stuckle
 
Posts: n/a
Default Re: problems with POST

moriman wrote:
> Hi,
>
> The script below *used* to work. I have only just set up a
> server, PHP etc again on my Win98 system and now it doesn't?
>
> On first loading this page, you would have
>
> $p =
>
> and the button image below it.
> On clicking the button the same page would reload but pass the hidden values
> (r=w & p=f)
> so that the first line of the page would then have
>
> $p = f
>
> This no longer works???
>
> <?php
> echo "<html><body>";
> echo "\$p = $p<br><br>"; //###
> $str = <<<HTM
> <head>
> </head>
> <body>
> <form action="" method="post">
> <input type="hidden" name="r" value="w">
> <input type="hidden" name="p" value="f">
> <input type="image" src="http://home/images/faq-up.gif" border="0"
> height="22" width="77">
> </form>
> </body>
> </html>
> HTM;
> echo $str;
> ?>
>
>
> on printing the $_ENV variables along with the the above script I find the
> following :
>
> QUERY_METHOD POST
> REQUEST_METHOD POST
> FORM_P f
> FORM_R w
>
> Is there something I haven't enabled in my
> setup of PHP that is stopping this from working now?
>
> Or has something changed with PHP, so that I have to do this another way?
>
> many thanks
>
> mori
>
>
>

How are you submitting your form? I don't see a submit button, for
instance.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #10 (permalink)  
Old 11-28-2005
vdP
 
Posts: n/a
Default Re: problems with POST

Jerry Stuckle wrote:
> moriman wrote:
>
>> <form action="" method="post">
>> <input type="hidden" name="r" value="w">
>> <input type="hidden" name="p" value="f">
>> <input type="image" src="http://home/images/faq-up.gif" border="0"
>> height="22" width="77">
>> </form>
>>

> How are you submitting your form? I don't see a submit button, for
> instance.
>

I thought the same till I looked up the HTML-specification at
http://www.w3.org/TR/REC-html40/inte...ms.html#h-17.4
Apparently the input of image type serves as a submit button.

vdP
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:28 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0