• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Block GET Call to method

#1
[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

#2
[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;
}

#3
[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.

#4
[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
}

#5
[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?

#6
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.