Re: Using $_GET for POST
| From: | Nitsan Bin-Nun | Date: | Thu, 31 Jul 2008 04:41:37 +0000 |
| Subject: | Re: Using $_GET for POST | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277513@lists.php.net to get a copy of this message | ||
Umm I suggest you try this code:
index.php:
<?php
$formContainer = <<<EOF
<form ACTION="index.php?this=is&awsome=dont&you=think"
METHOD="POST">
<input type='text' name='check' value='' /><br />
<input VALUE="submit" name='submitted'
TYPE="submit"></form>
EOF;
if (!isset($_POST['submitted']))
echo $formContainer;
else
{
echo "<xmp>";
var_dump($_GET);
echo "\n\n\n";
var_dump($_POST);
echo '</xmp>';
echo $formContainer;
}
?>
HTH,
Nitsan
2008/7/31 Robert Cummings <robert@interjinn.com>
> On Wed, 2008-07-30 at 22:18 -0400, Edward Diener wrote:
> > In handling an HTTP POST request I came across some PHP code, which I
> > need to modify for my own purposes, which has code like this:
> >
> > if ( ! (isset($_GET['xxxxx']) && $_GET['xxxxx'] == 20) )
> > {
> > // Do something by returning an error
> > }
> >
> > Can this ever be correct when the form looks like:
> >
> > <form ENCTYPE="multipart/form-data" ACTION=""
> > METHOD="POST">
> > <input NAME="SomeFile" TYPE="file">
> > <input VALUE="submit" TYPE="submit"></form>
> >
> > ?
> >
> > Is the $_GET possibly being used to check for an 'xxxxx' parameter being
> > passed in the query part of the URL ?
> >
> > I am fairly new to PHP so I am trying to understand how $_GET differs
> > from $_POST. Thanks !
>
> Yes this can be correct. Since the above action is set to blank, the
> form will submit to the same page as that on which is is presented. As
> such, if any GET parameters were set in the URL, they will be
> re-presented upon submission along with any POSTed data.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>