Database
Judging by your code, I see that you are not using the latest version of CI (2.0.2 from 06/12).
As pointed out in changelog , the getwhere() function getwhere() now called get_where() ) was left as for version 2.0.
As for the ubiquitous application, you are strongly advised to update the current version, as there were many fixes at the same time, and you should always rely on the safest version.
mysql_real_escape_string is usually considered "sufficient" to provide a high level of security in your queries, but, as happened with its predecessor (mysql_escape_string), it is not 100% safe against all types of attacks, so relying on it is not very good. Despite security, there are still attacks that can get past this filter.
Check, among many, this question on SO for more information on this.
In codeignier: If you are developing your own application, I suggest you at least use the mysqli extensions or, even better, the PDO class; prepared statements are undoubtedly safe and should be approved in everything else.
But we are in the context of structure, and Codeigniter offers 3 great ways to safely query your database by applying the right tool to the correct input without having to worry about it. I'm talking about query bindings and manual escaping using the $ this-> db-> escape () family and Active Record Class
You can find usage examples in the URLs I just linked, or read answers from other peers here, so I wonโt go into the details of each procedure in this post.
Password
As for your password, as already stated by other users, md5() is now an invalid hashing algorithm. There are rainbow tables there that can crack your md5 password in a relatively short amount of time, so you are better off with higher levels of security hashing, such as sha1 () or sha256, sha512 and others
In codeigniter: Codeigniter comes with a security helper class that provides you with a convenient do_hash() function (maybe dohash() in your old installation) that can be assigned a hashing alg. as a parameter (currently I think it only supports md5 and sha1) and sha1 () is used by default.
Other observations
I donโt quite understand why you blame your login for your SQL injections. Are these 2 forms in your entire application?
You do not provide information to find out if you use the $ _GET parameters or follow your own URI segmentation, but I believe that you do this, so I assume that you are safe from this point of view.
You have to make sure that there is no other input form on your site that contains the input coming into the database, otherwise you can protect your login as much as you want, but someone can penetrate the backdoor and read your database table from there and log into your site in a "legal" form.
In addition, there may be another source of intrusion, for example, a compromised cookie. As a piece of advice, when you decide to use the framework (and you do yourself a lot better than developing from scratch and all by yourself), you should use the MOST of your functions, especially when it comes to security. This is a huge and very sensitive issue, so you MUST give this topic your top priority, and a well-designed structure with a huge community and frequent updates is closest to the security you can get.
Therefore, you are advised to update the CI installation (manuals can be found here in your manual. Choose your version and follow the instructions), always use the top tools that you give for each task, and do not think that blocking your door will make you safe from intruding from your windows. Always check and study all possible causes.
Late addition: Don't forget XSS, CSRF, session commit, and other hot security issues.