Forum Moderators: coopster
I was curious about how I should do this. I had something worked out before that would check to see if it was numeric but people kept complaining they were getting errors because of it.
I was curious what everyone here uses for situations like that. Also, what are other ways I could secure my site? Like Forms, when a user inputs info, that could be one. What others could there be?
Thanks :)
Wes
I set it up with:
function id_check($id) {
if (preg_match("/[^0-9]/",$id)) {
return 10;
} else {
return $id;
}
}
I set it up like this so if they do enter a bad id, it will return them with another which is also the most popular id used. Also I set it up so when an error does occur it emails me with the id they entered and their ip. That was easy, now hopefully I don't get a lot of errors like I did before.
Thanks for the replies. :)
What about other ways of securing my site. What have you found to be another important way to protect your database?
Thanks.
Wes
[edited by: Salsa at 7:02 pm (utc) on Nov. 15, 2004]
The most important aspect of protecting your database is to make sure that any values (even numeric) are quoted within your query and are properly escaped.
The function mysql_escape_string() [uk.php.net] exists to do just that.