[FX.php List] $_REQUEST

Chris Hansen chris at iViking.org
Thu Jul 31 10:40:13 MDT 2008


Here's my approach (note that you can see this in the Book_List  
example, too -- though that solution admittedly needs some updating =):

$arrayName = '_' . $_SERVER["REQUEST_METHOD"];
foreach ($$arrayName as $key => $value) {
     /* code here */
}

Note that this makes your code completely flexible, AND it only pays  
attention to data sent via the current request method (no ambiguity  
with GET and POST parameters with the same name...)

HTH

--Chris Hansen
   FileMaker 7/8/9 Certified Developer
   Creator of FX.php
   "The best way from FileMaker to the Web."
   www.iViking.org

On Jul 30, 2008, at 5:41 PM, Nick wrote:

> 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
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list






More information about the FX.php_List mailing list