Hi-ho!
I agree with the poster above: error/manipulation checking is mandatory. I do it twice: first with javascript for user friendlyness (user don't need to submit to be told where he err), then again by php when the data reaches the server.
I'm using several functions, with different checking depending on wether the user is authenticated or not (authenticated users may be allowed to use html-tags, for example).
Here's some of the clean-up functions:
## Function for the ones we trust ;-) ##
function dbIn($text) {
$text = strip_tags ($text, "<ul>,<ol>,<li>,<b>,<i>");
$text = str_replace(chr(10),"",$text);
$text = str_replace(chr(13), "<br>", $text);
$text = addslashes($text);
return($text);
}
## Function for the not-trusted ##
function dbInsans($text) {
$text = strip_tags ($text, "");
$text = str_replace(chr(10),"",$text);
$text = str_replace(chr(13), "<br>", $text);
$text = str_replace("\"","*",$text);
$text = str_replace("\'","*",$text);
$text = addslashes($text);
return($text);
}
If you're starting afresh you should also code with intention of having globals set to off (mine aren't... :rolleyes: ) to further limit the attackers possibilities.
I also go through my scripts and close the possibilities for any url-manipulation of non-post/get/cookie vars (ie. vars that is fetched and processed by script only - not submitted). Guess that's not so important when the globals are off, but anyway - on top of any auth'ed page there's bound to be something like:
if($server_auth_hash != "") {
die("Yeah, as if...");
}
because the server_hash is a value generated by the server, further down in the script.
Just go through every key auth value and close the possibility for any "pre-generated" existence 😃
Then there's the sql-manipulation.
I've recently surfed a lot on dubious hacker-sites to try to unlock some of the secrets they use (but you didn't understand a word, did you, knutm?), and found that the manipulation of sql is quite easy. Shan't delve into this here, but as a reference:
http://mel.ini2.net/p/sql_injection_walkthrough.txt
http://www.hackersplayground.org/papers.html
And it's vital to turn of error-reporting in php, and protect any inc's from being read directly.
knutm