Ask a Question related to PHP Development, Design and Development.
-
Jeff #1
$_GET AND $_POST in harmony !
I've been struggling with this since I started writing web apps. I cannot
wrap my brain around a universal function for handling GET AND POST data.
I have written several functions to handle but none really satisfy. I
usually end up going back to $_GET['var_name'] (or POST) especially when it
comes to handling databsae inserts and updates.
Does anyone know where or have code that can give me a good foundation on
writing a 'semi-universal' function/class to handle post and get requests.
Thanks in advance.....
- j
Jeff Guest
-
Accepting variables via $_GET and $_POST in same script ?
usenet@isotopeREEMOOVEmedia.com wrote: Use $_SERVER to determine what HTTP request method was used to access your PHP script. ... -
#25231 [Bgs]: Strange $_GET/$_POST Behaviour
ID: 25231 Updated by: sniper@php.net Reported By: tim at zero-interactive dot com Status: Bogus Bug Type: ... -
#25231 [Opn->Bgs]: Strange $_GET/$_POST Behaviour
ID: 25231 Updated by: sniper@php.net Reported By: tim at zero-interactive dot com -Status: Open +Status: ... -
#25231 [Opn->Fbk]: Strange $_GET/$_POST Behaviour
ID: 25231 Updated by: iliaa@php.net Reported By: tim at zero-interactive dot com -Status: Open +Status: ... -
#25231 [NEW]: Strange $_GET/$_POST Behaviour
From: tim at zero-interactive dot com Operating system: Win2K Pro PHP version: 4.3.2 PHP Bug Type: Variables related Bug... -
johannes m.r. #2
Re: $_GET AND $_POST in harmony !
Since in theory (and also in practice;) both can be set at the same
time you will have to decide which to chose at some point.
I use something like
$name = (isset($_GET['name'])) ? $_GET['name'] :
(isset($_POST['name'])) ? $_POST['name'] : "no name entered!";
(I hope I didn't forget any brackets now:)
Regards,
johannes
johannes m.r. Guest
-
Nathan Gardiner #3
Re: $_GET AND $_POST in harmony !
Jeff wrote:
You can use $_REQUEST to retrieve form variables whether they were sent via> I've been struggling with this since I started writing web apps. I
> cannot wrap my brain around a universal function for handling GET AND
> POST data.
>
> I have written several functions to handle but none really satisfy. I
> usually end up going back to $_GET['var_name'] (or POST) especially
> when it comes to handling databsae inserts and updates.
>
> Does anyone know where or have code that can give me a good
> foundation on writing a 'semi-universal' function/class to handle
> post and get requests.
>
>
> Thanks in advance.....
>
> - j
POST or GET.
Nathan
Nathan Gardiner Guest
-
Jeff #4
Re: $_GET AND $_POST in harmony !
Thanks Nathan,.....
I had read something about that a few releases ago but was under the
impression that REGISTER_GLOBALS would need to be enabled....my bad !!
I have been testing with it over the past week but I wasn't sure if this was
the ultimate or 'recommended' approach to coding.....
anywho....Thanks again !!
"Nathan Gardiner" <nate@nate.id.au> wrote in message
news:40bdd08f$0$326$c3e8da3@news.astraweb.com...via> Jeff wrote:>> > I've been struggling with this since I started writing web apps. I
> > cannot wrap my brain around a universal function for handling GET AND
> > POST data.
> >
> > I have written several functions to handle but none really satisfy. I
> > usually end up going back to $_GET['var_name'] (or POST) especially
> > when it comes to handling databsae inserts and updates.
> >
> > Does anyone know where or have code that can give me a good
> > foundation on writing a 'semi-universal' function/class to handle
> > post and get requests.
> >
> >
> > Thanks in advance.....
> >
> > - j
> You can use $_REQUEST to retrieve form variables whether they were sent> POST or GET.
>
>
> Nathan
>
>
Jeff Guest
-
Peter Pagé #5
Re: $_GET AND $_POST in harmony !
"Jeff" <x_cipher@hotmail.com> wrote in message
news:c9ilfv026a6@enews1.newsguy.com...> I've been struggling with this since
I started writing web apps. I cannotit> wrap my brain around a universal function for handling GET AND POST data.
>
> I have written several functions to handle but none really satisfy. I
> usually end up going back to $_GET['var_name'] (or POST) especially when> comes to handling databsae inserts and updates.
>
> Does anyone know where or have code that can give me a good foundation on
> writing a 'semi-universal' function/class to handle post and get requests.
Sorry, it's it's been a long day so I can't figure out where this is off
topic or not... I just extract everything so I don't have to worry about
whether or not it's a "post" or a "get" variable. I put the following
commands at the top of my scripts:
extract ($_POST);
extract ($_GET);
Once that's been done, an input field named "fred" for example is
accessible quite simply as "$fred", whether it came back via a GET or a
POST. It's my responsibility to ensure that I don't overwrite anything by
executing those commands, but I've never had to think much about this... I
know what my variables are! I wouldn't even mention this except that I've
only recently realized while reviewing someone else's code that this
approach is not widely known. It may not be appropriate for your
application, but just in case...
Peter
Peter Pagé Guest
-
Marc Nadeau #6
Re: $_GET AND $_POST in harmony ! Thanks
Peter Pagé a schtroumphé:
I don't know if your post has been usefull for the OP; it is for> "Jeff" <x_cipher@hotmail.com> wrote in message
> news:c9ilfv026a6@enews1.newsguy.com...> I've been struggling
> with this since
> I started writing web apps. I cannot> it>> wrap my brain around a universal function for handling GET
>> AND POST data.
>>
>> I have written several functions to handle but none really
>> satisfy. I usually end up going back to $_GET['var_name']
>> (or POST) especially when>>> comes to handling databsae inserts and updates.
>>
>> Does anyone know where or have code that can give me a good
>> foundation on writing a 'semi-universal' function/class to
>> handle post and get requests.
>
> Sorry, it's it's been a long day so I can't figure out where
> this is off
> topic or not... I just extract everything so I don't have to
> worry about
> whether or not it's a "post" or a "get" variable. I put the
> following commands at the top of my scripts:
>
> extract ($_POST);
> extract ($_GET);
>
> Once that's been done, an input field named "fred" for
> example is accessible quite simply as "$fred", whether it came
> back via a GET or a
> POST. It's my responsibility to ensure that I don't
> overwrite anything by executing those commands, but I've never
> had to think much about this... I
> know what my variables are! I wouldn't even mention this
> except that I've only recently realized while reviewing
> someone else's code that this
> approach is not widely known. It may not be appropriate for
> your application, but just in case...
>
> Peter
me.
I'm building a php app with about 30 complex forms and that
trick will save me hours of typing (and typos). I tried it
today and it works perfectly.
I wonder why i did not find this before.
Thanks again.
--
mv cso /dev/null
Marc Nadeau# La Pagerie /* [url]http://www.pagerie.com[/url] */
Marc Nadeau Guest
-
Abubakar #7
Re: $_GET AND $_POST in harmony !
please explain this.....................
Abubakar Guest



Reply With Quote

