Welcome Guest, Not a member yet? Register   Sign In
How are you detecting postback?
#1

[eluser]Damien K.[/eluser]
How are you detecting postback?

No need to tell me how CI does it, because I already know. How are you doing it?
#2

[eluser]wiredesignz[/eluser]
Maybe you could explain how CI does it. Wink
#3

[eluser]Damien K.[/eluser]
Maybe I can't and was just bluffing. Smile

count($_POST) == 0
#4

[eluser]wabu[/eluser]
You could extend Controller and add something like the following (to MY_Controller):

Code:
function is_post() {
  return $_SERVER['REQUEST_METHOD'] == 'POST';
}
#5

[eluser]steelaz[/eluser]
My submit buttons usually have: name="submit", so I just:

Code:
if ($this->input->post('submit'))
{
    // do it
}
#6

[eluser]BrianDHall[/eluser]
I check for some specific required field, usually the most 'obvious' one, and I also have the tendency to put hidden fields in my forms that I check for to be definitive on just what form is being submitted. Some forms I actually use this to handle form submission in my constructor or MY_controller (I handle login this way, so if there is $this->input->post('login_request') is true I try to log the user in before doing anything else). The advantage there is that I can build any form, anywhere on the site, in any way I want and have it 'just work' so long as I stick the right hidden form field or even drop-down field option in a form somewhere.
#7

[eluser]Damien K.[/eluser]
Looks like all the intuitive ways to detect postback have been mentioned. Thanks, everyone, for all the feedbacks.

My implementation is the same as wabu's way, except I extend Form_validation instead.




Theme © iAndrew 2016 - Forum software by © MyBB