From the course: PHP with MySQL Essential Training: 1 The Basics
Unlock the full course today
Join today to access over 25,100 courses taught by industry experts.
Challenge: Validations
From the course: PHP with MySQL Essential Training: 1 The Basics
Challenge: Validations
- [Instructor] We're ready for another challenge assignment. This time, your challenge is to take the work that we've done this chapter on validations and apply it to your pages so that we validate the data before we accept it and put it in the pages table. You'll want to begin by writing a validation function so that you can pass in an associative array that can take a look at that data and decide if there are any errors and it'll return any errors that come up. Don't forget that our pages table has columns for subject ID and content that our subjects table did not have. So make sure you consider how you might want to validate those. Once you've got that function written, then you'll want to make use of it. You'll want to validate data before you create a page, and also before you update a page. Once you have those validations in place and errors being returned, we'll be ready to display those errors back to the user. And you'll do that both on the new.php page and the edit.php page.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.