CodeIgniter Forums

Full Version: Block GET Call to method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Ceros[/eluser]
Hi,

I know that in ASP.NET MVC there is something called AcceptVerbs. So you can do this:

<AcceptVerbsTongueOST>_
function insertdatabase(param1, param2)...

Using this, when you directly call www.mysite.com/controller/insertdatabase it doesn't work. But it will if you are using a form with method="POST".

Is there a way to do the same thing in CI?

Thanks!
Seb

El Forum

[eluser]brianw1975[/eluser]
without further definition of "it doesn't work" my response is:

eh....uh....

Code:
if($this->input->post("submit")){
//do your junk here
}else{
exit;
}

El Forum

[eluser]Ceros[/eluser]
[quote author="brianw1975" date="1266205864"]without further definition of "it doesn't work" my response is:

eh....uh....

Code:
if($this->input->post("submit")){
//do your junk here
}else{
exit;
}
[/quote]

And this won't work if you are using jQuery and dialog.

El Forum

[eluser]Ceros[/eluser]
Nevermind, I found this:

$_SERVER['REQUEST_METHOD']

Return GET or POST

so all you have to do is:

Code:
if($_SERVER['REQUEST_METHOD'] == "POST"){
   //do stuff
}else{
   //return to index or error page
}

El Forum

[eluser]brianw1975[/eluser]
[quote author="Ceros" date="1266210202"][quote author="brianw1975" date="1266205864"]without further definition of "it doesn't work" my response is:

eh....uh....

Code:
if($this->input->post("submit")){
//do your junk here
}else{
exit;
}
[/quote]

And this won't work if you are using jQuery and dialog.[/quote]

:-S
seriously?
you didn't think that that might be pertinent information in your OP?

El Forum

[eluser]Ceros[/eluser]
Sorry, i was just searching for the equivalent of AcceptVerbs. I didn't think that jQuery would have change something. Anyway, you gave me a good hint so thank you.