Form: GET works but POST doesnt!?

C

CRON

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
 
C

Chris F.A. Johnson

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?
 
S

Steven Saunderson

On Thu, 19 Oct 2006 21:56:01 -0400, "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;
}
 
N

Nico Schuyt

Steven said:
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'];
 
J

jojo

Steven said:
> [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.
 
J

jojo

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.
 
J

Jonathan N. Little

jojo said:
Steven said:
[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
)
 
J

Jonathan N. Little

Jonathan said:
jojo said:
Steven said:
[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
 
J

jojo

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?
 
J

Jonathan N. Little

jojo said:
Jonathan N. Little wrote:
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?

If the 'parameter' is sent via POST and included via URL simulating a
GET (how I did the test) that values discrete within respective $_POST
and $_GET arrays but in $_REQUEST the POST will trump the GET. That was
all I was illustrating.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top