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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs