O'Reilly logo

PHP & MySQL: The Missing Manual by Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. When Things Go Wrong (and They Will)

So far, you’ve got a growing, functioning set of scripts. You’ve got some web pages that interact with them, CSS to style both your static HTML pages and the HTML that your scripts output, and you can even go in and add some client-side JavaScript validation. Things are looking pretty good.

Note

Make that stronger: you should go in and add some client-side JavaScript validation.

But there’s a monster lurking in the deep. While you’ve occasionally added a die or a conditional statement to make sure your queries return a result row, your code still assumes a perfect user. Someone who always types what you expect, never enters a phone number in the email field or spaces in the Facebook URL field; someone who never needs to go back and so never clicks the browser’s Back button at an inopportune time; and never enters her information into the same form twice, furiously clicking “Add my information” instead of waiting on her lousy Internet connection.

Of course, nobody’s that perfect—especially at a computer. The reality with web applications—and in fact any type of software—is that people always find ways to break your best-intended pages and forms and scripts. They supply bad information, leave out required fields, and make a general mess of anything that you’ve not planned on being messy.

Note

Once again, client-side JavaScript seems awfully valuable to mention here. You can reduce a lot of this sort of problem by validating your user’s information ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required