This video will be available to
subscribers on Thu, Jun 12, 2025.
You must be a subscriber to view this video.
Jun 12, 2025
18m:5s

Invalid Form Submissions

Classification
Software Engineering | Languages | PHP
Keywords
oop | php

About This Episode:

In this video, we tackle the next critical part of the form experience—handling invalid submissions with grace. When a user submits a form with missing or incorrect data, we want to redirect them back, repopulate the form, and show helpful error messages. 💡

Here’s what we build in version v19-redirect-with-errors:


- Define the ideal usage:
- session()->invalid($errors)->redirect_back();
- Then… we make it real! 💥
- Introduce invalid() and redirect_back() methods in the Session class
- Store transient $old and $errors values to survive the redirect and improve UX ✨
- Refactor Session::old() into a more flexible Session::flash() and flash_message() pattern 🔁
- Improve the old($key, $default) helper to escape HTML using htmlspecialchars() for security 🛡️
- Add a validation_message() helper to display specific errors next to form fields
- Update the review form:
- Loosen validation so comment is optional
- Add hidden rating input with default of 0
- Test with extreme values (e.g., rating=10, long name) to confirm validation is triggered
- Clean up temporary debug outputs (like var_dump()) and finalize the flow ✅


This update makes your app smarter, friendlier, and much more user-friendly when things go wrong. A polished user experience, even on failure? Now that’s pragmatic. 🚀
Bob Cravens

Bob Cravens

Your Instructor
more »
Owner
TekFoundry
Wisconsin
United States
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.

At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.

Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.

When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.