kclark wrote:I am checking to see if the Submit button on the form at the bottom of the page has been pressed. I don't understand your suggestion. The way that I did it is the only way that I knew how.
You're checking to see if it was pressed by directly accessing it. If that variables doesn't exist, you'd be attempting to assign the value of a non-existent array item to the $Login variable. In other languages, this can cause problems varying in moderate to severe (e.g. segmentation faults or something of that nature). In PHP, you fortunately only generate E_NOTICE level error messages.
Instead, you should first see if that external data exists in a safe manner, e.g. using [man]isset/man or [man]empty/man in the if() statement.
kclark wrote:This code is word for word the same as on another site and it works flawlessly for me.
IMHO, nothing works "flawlessly" if you can't set error_reporting to E_ALL and have no errors logged. It will usually work (despite the E_NOTICE messages), however, simply thanks to how graciously PHP can handle such code (which is IMHO somewhat poorly written).
kclark wrote:The username and passwords are supplied to my viewers from me. They are not md5.
Well of course they are, I wasn't expecting the users to go hash their passwords with the MD5 algorithm and then type in that hashed value.
The code comment suggests that you are to be hashing the password using MD5. This led me to assume that the passwords were thus stored in your database not in plaintext but as MD5 hashes, meaning that simply checking if "password='johndoe'" would always fail since you aren't hashing the user's password before querying the DB.
kclark wrote:Where/How do I sanitize the data and is there a way to see if my code, not just this page can be attacked?
The "where" is before you use any user-supplied data in a SQL query. The "how" is a complex answer (though many of the complexities can be mitigated by learning how to use prepared statements). SQL data sanitization and security isn't a topic that you can learn in a sentence or two.
The PHP manual does have a brief introduction to the topic here: [man]security.database.sql-injection[/man].
kclark wrote:In this particular db, I only have 3 fields. Username, Password, and Live. That's it.
Um... okay? Not sure what the relevance of any of that is? 😕
kclark wrote:Is this a php4 thing or php5?
Both. While it was only "officially" deprecated since PHP 5.3, there have been warnings against using it since PHP 4.2. I say "officially" because that's when the PHP manual listed it; the PHP community as a whole probably decided it was a bad idea before that.