[FX.php List] $_REQUEST

Nick whatdoyouwant at gmail.com
Wed Jul 30 17:41:46 MDT 2008


You can actually use both GET and POST variables and they work very well
together.

here's some example:
my html form:
<form method="post" action="this.php?cmd=new">
<input type="text" name="email" />
<input type="submit" value="Create new email" />

and my processing text in "this.php"
<?php
if (isset($_GET) && isset($_GET['cmd']))
{
      if ($_GET['cmd'] == 'new') {
       $my_find = new FX();
       $my_find->layout = 'web_email';
       $my_find->AddDBParam('email', $_POST['email']);
       $my_find_result = $my_find->FMNew();
        $record = current($my_find_result['data']);
      }
}
?>

Of course, I use -modid in case a user goes back a page, and submit that
with the form, among other things
for example i always do a find on the record i'm viewing before anything...
to determine permissions and such.
and on a new record i usually use header('Location:
this.php?record='.$record['ID'][0].'&cmd=view');
or something like that....there are a few things to validate that I'm not
doing in the example.


On Wed, Jul 30, 2008 at 4:17 PM, Jonathan Schwartz <jschwartz at exit445.com>wrote:

> Hi Folks,
>
> I've been rethinking how to handle forms and validation.
>
> Sometimes the data being validated comes from a POST and sometimes a GET,
> depending on whether the data was generated from a Form or a link.
>
> Up until now, I have had to deal with both cases ...if($_GET[] ) and
> if($_POST).
>
> I just realized that I can use $_REQUEST and not worry which type the data
> came from.
>
> Is this a valid way to go?  Something tells me that $_REQUEST isn't.
>
> Thanks
>
> J
> --
> Jonathan Schwartz
> Exit 445 Group
> jonathan at exit445.com
> http://www.exit445.com
> 415-370-5011
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://localhost/pipermail/fx.php_list/attachments/20080730/1005b1a5/attachment.html


More information about the FX.php_List mailing list