Hi there zabmilenko, and thank you so much for taking the time to look at it:
1) What is the best way to protect from this? Simply make sure that the input contains nothing but numbers, with a limit(ie; only 5 characters)?
2) This thread explains it completely, but in short, I needed a way to turn of the db connection just for step 1 of the install script(checking db connection variables), or else they would get an error. Step one sets the value, but nothing else in the script ever uses it. Is this ok?
3) If I use mysql_real_escape_string() to input data, what do I use when I pull the data(synonymous with addslashes)? I checked the php manual for the answer, but I don't see mention of anything. Am I just to use mysql_real_escape_string() again?
4) Do you mean:
if ((@is_readable(install)) && is_dir(install)){
should be:
if ((@is_readable('install')) && is_dir('install')){
? It's intended to check for the existence of the install directory, and stop the script if it's found.
5)
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
Same as number 1. What is the best method for protecting against this? There should only be one admin, so maybe the script can match against it and null the input if it isn't what was expected?
6) Unfortunately, I can't answer that, as I simply used a tutorial at PHP Easy Step to build the login system. Should that part be stripped?
7) before I added the stripslashes to my retrieval of the content, my text looked like this when it was printed to screen:
I\'m thinking now that I\'m not so good that this php stuff.
When I added stripslashes to all of the content, that went away. I don't understand how I doubled up on it in any way. Are there instances where stripslashes shows up twice for a variable?
Also, Magic Quotes: Do I have to check for this being enabled on the host server before being able to use it?
(This isn't mine, but instead is from the PHP.net site)
// Quote variable to make safe
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
// Connect
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
OR die(mysql_error());
// Make a safe query
$query = sprintf("SELECT * FROM users WHERE user=%s AND password=%s",
quote_smart($_POST['username']),
quote_smart($_POST['password']));
mysql_query($query);
Is this what I need to do, both for the login and for all data being inserted?
8) I did this only because it's what I've seen in all of the scripts I've worked with. I understand now that it's reversible after looking it up. 🙁 I'll look into other encryption methods.
Thanks again for taking the time to help, and I'm sorry that your effort has so far only been rewarded with more questions.
thanks,
json