CakePHP: Deny GET Form Fields in URL

I have a CakePHP search form with 'type'=>'get'. Basically, one of the elements in the form is a button to send an image of a type. When the form is posted, in the URL I always get these x and y coordinates of the submit button:

http://site.com/controller/action ? x = 22 & y = 36 & query = hello

Is there a way to prevent the display of coordinates in the url? The reason is because someone else could use the same URL to perform the same search, without this unintuitive material in the link.

Thank!

+3
source share
3 answers

javascript :

document.getElementById('myImageButton').onclick = function() {
    this.form.submit();
    return false;
};

, beforeFilter , URL. , 2 HTTP-.

+3

, Post/Redirect/Get.

CakePHP:

POST GET:

  • " ?".
  • /
  • CakePHP SEF, URL- /search?q=contact /search/contact
+1

submit button .

echo $this->Form->**button**($this->Html->image('header_search_icon.png'), array(**'type'=>'submit'**));
0

Source: https://habr.com/ru/post/1726395/


All Articles