← Back to Course

Handling Form Requests

Forms are one of the most common ways users interact with a web application, whether they're signing up, submitting a comment, or updating a profile. Laravel provides a consistent way to receive and work with that submitted data.

Submitting a Form

A typical Blade form posts to a named route, and Laravel automatically expects a CSRF token to be present for any state-changing request made from a browser. This token is generated per session and verified automatically by Laravel's middleware.

Reading Submitted Data

Inside a controller, the incoming request is represented by Laravel's Request object, which is automatically injected when type-hinted in a method. From there, individual fields, all input, or only specific fields can be pulled out as needed.

MethodWhat It Returns
$request->input('name')A single field's value
$request->all()Every submitted field as an array
$request->only(['name','email'])Just the specified fields
$request->has('field')Whether a given field was submitted
$request->file('avatar')An uploaded file, if one was included

Good Practices for Handling Forms

Reading form data is only half the job — before anything is saved, it needs to be checked for correctness, which is exactly where Laravel's validation system comes in.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course