Welcome Guest, Not a member yet? Register   Sign In
Better than if(count($_POST) > 0)
#28

[eluser]toopay[/eluser]
[quote author="veledrom" date="1330686793"]Hi,

I want to check if POST occurred or not. Currently I'm using code below. I wonder if there is a better way of doing it with CI?

Thanks

Code:
do_save()
{
   if(count($_POST) > 0)
   {
      //Validate fields with form validator
   }
   else
   {
      redirect('index');
   }
}
[/quote]

form_validation class already including the POST inspection within its procedure, so this is more than enough :
Code:
function do_save()
{
   // Set validation rule
   // ...

   if($this->form_validation->run())
   {
      // save
   }
   else
   {
      redirect('index');
   }
}


Messages In This Thread
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 04:13 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 04:45 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 05:13 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 05:19 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 05:42 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 05:52 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 07:34 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 07:37 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 07:41 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 08:45 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 09:22 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 09:58 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 10:08 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 10:20 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 10:49 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 10:53 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 11:54 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 11:59 AM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 12:07 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 12:22 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 12:54 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 01:47 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 02:20 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 02:23 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 02:34 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 02:46 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 03:05 PM
Better than if(count($_POST) > 0) - by El Forum - 03-02-2012, 09:39 PM
Better than if(count($_POST) > 0) - by El Forum - 03-03-2012, 09:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB