For those of you new to programming (as well as those who are not), you should be made aware that security is a vital component to a game to ensure its success. Why is this the case you ask? Well, we just have to remember the golden rule of security: never trust a user’s input.
Yes, that means EVERY user!
You never know what kind of text a user will put in, so you really have to be aware of this problem. As a game owner, you no doubt have to account for the user’s input; otherwise, who knows what will happen to your website!
There are many other things you have to look out for, like SQL injection, JavaScript injection, and many other security problems. With all of these different things spinning around in your head, you’re ready to tear your hair out, right?
Well, don’t you worry, there are some things that you can do in order to ensure that your game doesn’t get compromised! Here are a few:
- Make sure input is of the correct datatype – Very simple and the easiest way to ensure your game’s security. So, for example, if you want them to input a number, make sure that what they put in is in fact a number! You can do this in PHP with ctype_digit().
- Make sure input does not contain any SQL text – Again, something that certainly has to be done! In PHP, you can use mysqli_real_escape_string() (as mysql_real_escape_string() is deprecated!).
- Make sure input falls under any specific guidelines you set – This basically means that if for example, you want a number greater than zero, that you ensure that the number is greater than zero! It is something that can be easily checked, but if you fail to do this, it could break your code and cause major headaches. That would be bad news!
This all sounds very simple (and it is), but ignoring these validation checks can really change a game that would be fantastic into a game of misery and emptiness.
I will be talking in more details about this in a later blog post, so stay tuned!
That’s all for now, until next time…keep that tech gear ticking.
~Goliath7470
