DEV Community

Precious Oladele
Precious Oladele

Posted on

3 2

Codeigniter 4 Post Request

Alt Text

Hello, how you doing?, For you to be here , that means you have a basic knowledge on how codeigniter 4 works or you just wanna try it out.

So in this case we will be looking at how to send POST request from view to controller and back to the view, Lets dive in.

Step 1. Set up a new codeigniter 4 project, Docs : Codeigniter

Step 2. Create a controller and pass in this.

public function post(){
if($this->request->getMethod() == 'post'){
echo "Hello world";
}
}
Enter fullscreen mode Exit fullscreen mode

Step 3. in your view create a form and add a button.
Like this

<form action="" method="post">
<button>Click me </button>
</form>
Enter fullscreen mode Exit fullscreen mode

Thats all, its not something more complex or buggy.. its just simple..

Please subscribe to my channel DevStack

Tiugo image

Modular, Fast, and Built for Developers

CKEditor 5 gives you full control over your editing experience. A modular architecture means you get high performance, fewer re-renders and a setup that scales with your needs.

Start now

Top comments (0)

Jetbrains image

Is Your CI/CD Server a Prime Target for Attack?

57% of organizations have suffered from a security incident related to DevOps toolchain exposures. It makes sense—CI/CD servers have access to source code, a highly valuable asset. Is yours secure? Check out nine practical tips to protect your CI/CD.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay