Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Form: GET works but POST doesnt!?

Reply
Thread Tools

Form: GET works but POST doesnt!?

 
 
CRON
Guest
Posts: n/a
 
      10-20-2006
Hi all:
I'm a little confused here: When I submit this form with GET it works
like a dream. But when I use POST, the recieving script just doens't
recieve the vars. Why would this be?

the form:
<form action="0scripts/invite.php" method="POST" enctype="text/plain"
onSubmit="compileEmails()">
<textarea name="notes" cols="65" rows="5"
id="notes"></textarea>
<p>Your invitation will be sent to the following email
addresses:
<input name="loopcount" type="hidden" value="<? echo
$loopcount;?>">
<br>
<textarea name="emaillist" cols="81" rows="5"
id="emaillist" style="background:#FFFFFF; border-color:#FFFFFF;
color:#999999; font-weight:normal; font-size:7pt;"></textarea></p>
<p align="right" class="backLightGrey">
<input type="submit" name="Submit" value="Send Invites"
</p>
</form>


Thanks a lot
Ciarán

 
Reply With Quote
 
 
 
 
Chris F.A. Johnson
Guest
Posts: n/a
 
      10-20-2006
On 2006-10-20, CRON wrote:
> Hi all:
> I'm a little confused here: When I submit this form with GET it works
> like a dream. But when I use POST, the recieving script just doens't
> recieve the vars. Why would this be?
>
> the form:
><form action="0scripts/invite.php" method="POST" enctype="text/plain"
> onSubmit="compileEmails()">
> <textarea name="notes" cols="65" rows="5"
> id="notes"></textarea>
> <p>Your invitation will be sent to the following email
> addresses:
> <input name="loopcount" type="hidden" value="<? echo
> $loopcount;?>">
> <br>
> <textarea name="emaillist" cols="81" rows="5"
> id="emaillist" style="background:#FFFFFF; border-color:#FFFFFF;
> color:#999999; font-weight:normal; font-size:7pt;"></textarea></p>
> <p align="right" class="backLightGrey">
> <input type="submit" name="Submit" value="Send Invites"
> </p>
></form>


Does the script that is targeted (0scripts/invite.php) support the
POST method?

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
 
Reply With Quote
 
 
 
 
Steven Saunderson
Guest
Posts: n/a
 
      10-20-2006
On Thu, 19 Oct 2006 21:56:01 -0400, "Chris F.A. Johnson"
<(E-Mail Removed)> wrote:

[snip]

> Does the script that is targeted (0scripts/invite.php) support the
> POST method?


To expand on what Chris says, GET variables are in the _GET array
whereas POST variables are in the _POST array. If you want to get them
from either array try something like :

function GetFormValue ($key, $default = '')
{
if (array_key_exists ($key, $_POST))
return $_POST [$key];
if (array_key_exists ($key, $_GET))
return $_GET [$key];
return $default;
}

--
Steven
 
Reply With Quote
 
Nico Schuyt
Guest
Posts: n/a
 
      10-20-2006
Steven Saunderson wrote:
> Chris F.A. Johnson


> [snip]
>> Does the script that is targeted (0scripts/invite.php) support the
>> POST method?


> To expand on what Chris says, GET variables are in the _GET array
> whereas POST variables are in the _POST array. If you want to get
> them from either array try something like :
> function GetFormValue ($key, $default = '')
> {
> if (array_key_exists ($key, $_POST))
> return $_POST [$key];
> if (array_key_exists ($key, $_GET))
> return $_GET [$key];
> return $default;
> }


Or: extract($_POST);
But isn't that a safety risc? I prefer $var=$_POST['var'];

--
Nico Schuyt
http://www.nicoschuyt.nl/


 
Reply With Quote
 
John Dunlop
Guest
Posts: n/a
 
      10-20-2006
[piggybacking]

> [CRON:]
>
> ><form action="0scripts/invite.php" method="POST" enctype="text/plain"
> > onSubmit="compileEmails()">


Only two enctypes must be supported: application/x-www-form-urlencoded
and multipart/form-data. The behaviour when the enctype is text/plain,
or any other content-type, is unspecified.

http://www.w3.org/TR/html401/interac...html#h-17.13.4

--
Jock

 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      10-20-2006
Steven Saunderson wrote:

> [snip]
>
>> Does the script that is targeted (0scripts/invite.php) support the
>> POST method?

>
> To expand on what Chris says, GET variables are in the _GET array
> whereas POST variables are in the _POST array.


The $_REQUEST-Array contains both, the POST and the GET variables. I'm
not surte what happens if the same variable is send by post and by get
but I would guess that the POST-value overrides the other.
 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      10-20-2006
Nico Schuyt wrote:

[how to read out $_GET and $_POST]

> Or: extract($_POST);


This does only make $_POST variables available but not the GET ones. You
have to add extract($_GET);.

> But isn't that a safety risc? >


It is. It has the same effect which was corrected by adding the
possibility to switch register_globals off: every variable which is
posted is set, no matter if the author of the script want it to be set
by the user or not. In some cases one can override the values of
variables in the script by simply posting variables with the same name
which is a security problem.

> I prefer $var=$_POST['var'];


The better poosibility. Only the variable you want to be set by post (or
get) are set, all the other post (or get) variables are ignored.
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      10-20-2006
jojo wrote:
> Steven Saunderson wrote:
>
> > [snip]
>>
>>> Does the script that is targeted (0scripts/invite.php) support the
>>> POST method?

>>
>> To expand on what Chris says, GET variables are in the _GET array
>> whereas POST variables are in the _POST array.

>
> The $_REQUEST-Array contains both, the POST and the GET variables. I'm
> not surte what happens if the same variable is send by post and by get
> but I would guess that the POST-value overrides the other.


Well does this answer it?

GET VAR
Array
(
[parameter] => ValueByGet
)

POST VAR
Array
(
[parameter] => ValueByPost
)


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      10-20-2006
Jonathan N. Little wrote:
> jojo wrote:
>> Steven Saunderson wrote:
>>
>> > [snip]
>>>
>>>> Does the script that is targeted (0scripts/invite.php) support the
>>>> POST method?
>>>
>>> To expand on what Chris says, GET variables are in the _GET array
>>> whereas POST variables are in the _POST array.

>>
>> The $_REQUEST-Array contains both, the POST and the GET variables. I'm
>> not surte what happens if the same variable is send by post and by get
>> but I would guess that the POST-value overrides the other.

>
> Well does this answer it?
>
> GET VAR
> Array
> (
> [parameter] => ValueByGet
> )
>
> POST VAR
> Array
> (
> [parameter] => ValueByPost
> )
>
>

Also not what happens when you access via the $_REQUEST array...

$_GET VAR
Array
(
[parameter] => ValueByGet
)

$_POST VAR
Array
(
[parameter] => ValueByPost
)

$_REQUEST VAR
Array
(
[parameter] => ValueByPost


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      10-20-2006
Jonathan N. Little wrote:

[snip]
>>>> To expand on what Chris says, GET variables are in the _GET array
>>>> whereas POST variables are in the _POST array.
>>>
>>> The $_REQUEST-Array contains both, the POST and the GET variables.
>>> I'm not surte what happens if the same variable is send by post and
>>> by get but I would guess that the POST-value overrides the other.

>>
>> Well does this answer it?
>>
>> GET VAR
>> Array
>> (
>> [parameter] => ValueByGet
>> )
>>
>> POST VAR
>> Array
>> (
>> [parameter] => ValueByPost
>> )
>>
>>

> Also not what happens when you access via the $_REQUEST array...
>
> $_GET VAR
> Array
> (
> [parameter] => ValueByGet
> )
>
> $_POST VAR
> Array
> (
> [parameter] => ValueByPost
> )
>
> $_REQUEST VAR
> Array
> (
> [parameter] => ValueByPost
>
>

This is just what I've said: If a variable is posted twice the
POST-value overrides the GET one. So where is the problem?
 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM
get a value in the servlet with get, but null with post Shiv Java 3 10-13-2003 01:58 PM



Advertisments