Week 9: Selection Check on the Events and Event Results Pages
- Julia
- Jul 4, 2019
- 1 min read
Today, my final task for the website was due: Making a check if at least category as well as one start date and one end date is selected by the user. If this is not the case, no results are shown and the user gets a reminder that he/she has to select the missing input.
I had already realised this solution with JavaScript before I learned that I had to use the invisible input fields to retrieve information that could be used in PHP.
Why can't the user just find result without a selection? The reason is that the SQL request does not work with empty values, which will result in just returning a PHP warning to the user. That does not only look ugly, but also as if our website is not working.
Because of that, I made a few adjustments to the code with if statements, giving out the error messages if not all the required inputs had been filled.

All the code that had been used to return the results from the database by default before is now only executed if the conditions are met.

And it works! This task was fairly easy now, but only because I had made such an effort to refresh my PHP skills in the first place.
Comentários