Forum Moderators: coopster
My question is, for security and/or convenience purposes, when do I need to addslashes to user input, and when do I need to stripslashes?
I do know I need to use mysql_real_escape_string on anything I plan to use in a database query. But say I don't need to use a database. In the following scenario, what do I need to do with slashes?
Do I need to add slashes at all under these circumstances since a database isn't involved? My concern is that a malicious user might be able to inject PHP code through a form or other input methods that would allow unauthorized access to the server. For instance, I think I remember seeing an example once of a PHP script with a security hole that would have allowed a hacker to enter PHP code into a form field and delete a website's root directory. Obviously I don't want that to happen! ;)
So again, if ALL I'm doing is processing the data with PHP and re-displaying it to the user, what do I need to do with adding or removing slashes if magic quotes are turned off?
Thanks in advance,
Matthew
if(!is_int($_POST['number'])) {
echo "The value entered is not an integer!";
exit();
}
I hope this explains a little. Good luck!