Send post on click of a link in cakephp 4.2

How can I send a post when I click on a link?
I have a site where I can click on two links (Enterprises and Affiliates) when I access it (when I click on each link it sends me to the login page), when I click on Affiliates I don’t want to show the link to Enterprises, but when I click on Enterprises I want to show all the links (when I login to the site with user and password I have a menu with all the links) what I need is that when I click on Enterprises it sends me a post variable named level equal to 2, and when I click on Affiliates equal to 1.
How can I do that?

Use javascript or a hidden form. Have the “link” run code which appends and posts a form, or post the hidden form.

A Google search of How can I send a post when I click on a link? gives javascript - Make a link use POST instead of GET - Stack Overflow examples.

The question isn’t clear to me. Both of these links should redirect to the login page, but one of them shows a different set of links on the login page than the other? Or they both redirect to the login page, and you want a different set of links to appear after they login? Or these links are on the login page? Or you want to load something onto the current page when you click one of these links completely unrelated to the login?

Please explain your desired process in more detail, because I’m not at all convinced yet that your best solution is actually to “send a post variable named level equal to 2”.

take a look at Form - 4.x

1 Like