Welcome Guest, Not a member yet? Register   Sign In
How to handle direct link to controller/function/param?
#5

[eluser]mddd[/eluser]
@Rob B: making the function "private" will make it so that you can't call it directly in a url. But then you will have to make another mechanism to call that function. So I don't see how this solves the problem of calling the delete action through a url.

I agree with n0xie that you should not call the action that way.
I usually send some information in POST variables. It's easy to write a small Javascript to set a form value to indicate that the user has indeed agreed to delete something.

Code:
// javascript
function areyousure(id)
{
  var test = window.confirm('Are you sure you want to delete item number '+id+' ?');
  if (test)
  {
  document.myForm.formaction.value = 'delete';
  document.myForm.submit();
  }
}

The uri could be /controller/edit/42 (for editing item 42) and in your 'edit' method you would check to see if $_POST['formaction'] is 'delete'.


Messages In This Thread
How to handle direct link to controller/function/param? - by El Forum - 04-06-2010, 12:15 PM
How to handle direct link to controller/function/param? - by El Forum - 04-06-2010, 02:44 PM
How to handle direct link to controller/function/param? - by El Forum - 04-06-2010, 03:19 PM
How to handle direct link to controller/function/param? - by El Forum - 04-07-2010, 02:56 AM
How to handle direct link to controller/function/param? - by El Forum - 04-07-2010, 05:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB