amy.damnit;10914291 wrote:Wow, that was a pretty consistent series of replies!
I'm new to web-programming and really wasn't sure what to think. (I guess I just assumed you always used JavaScript?!)
A few follow-up questions...
1.) Would you ever have to worry about server-side data validation creating a huge performance hit on a busy site (i.e. 100-200 concurrent users)?
I suppose you can worry about it; but at the same time you have to worry about what might happen if your script allows invalid data to be processed. Generally, when talking about pure PHP code, you're talking about differences in milliseconds (or less) of execution time when you add/delete relatively simple function calls and such. Probably the single most significant timing issues will be in the HTTP transfers back and forth over the network/internet, and database access/queries (and even that can be kept pretty lean if everything is designed optimally and the data being requested is not humongous). Adding a few validation rules would really be one of my least concerns when it comes to PHP script performance.
2.) Other than set choices in a list (e.g. drop-downs, list-boxes, radio-buttons, etc), is there any way to make data validation any easier for PHP?)
There are [man]filter[/man] functions, [man]ctype[/man] functions, [man]PCRE[/man] regexp functions, and a whole slew of string functions. You also need to be aware of issues with data that will be used in database queries (see [man]mysql_real_escape_string/man, for instance).
3.) On the client, is there any other way to legitimately valid data other than JavaScript?
There may be other ways in certain situations, such as if you use a Flash or Java applet, but regardless of what type of client-side validation you do, in the end the browser sends a HTTP request with the form data to your server-side script. Any hackers worth the name can easily spoof that request and send whatever POST/GET data they want to the form action's URL. Shoot, even I could do that. 😉