Problem with registeration system. (I'm using OOP and MVC)

Help.
I’m trying to build a registeration and login system, but I keep having this problem.

The data just doesn’t get received in the database!

Externally, the page doesn’t show me any error and functions like everything is alright.
I even tried putting a mysql_error() function after every query yet the page still doesn’t find anything wrong with it.

Please check my codes and try to find what’s wrong with them. :frowning:

controller/controller.php - pastebin.com/xCGuEKaa
model/model.php - pastebin.com/Qg8DF0f7
view/view_i.php - pastebin.com/FhPNjQGd
view/view_ii.php - pastebin.com/bLeGtiE7
sign_in.php - pastebin.com/CmK2FuUx

Hi zatoo,

Try replacing the following line in model.php:
[php]mysql_query(“INSERT INTO userlist(username, password, email) VALUES({$a}, {$b}, {$d})”); // insert user details into database[/php]

with
[php]mysql_query(“INSERT INTO userlist (username, password, email) VALUES(’$a’, ‘$b’, ‘$d’)”); // insert user details into database[/php]

It looks to me like you should be generating quotes around the text values, but I don’t believe that is happening. The replacement above should accomplish this. There are several ways to do the same thing, but the above line should ensure that this is happening.

I’ll try to look everything over in more detail as soon as possible, but this might be a good place to start.

Damn!
I can’t believe that little thing messed up my code entirely. It works now. You did it.
How’s the rest of the code? Am I doing the rest properly?

Great to hear that it’s working!

As to the rest of the code, the only other things that I noticed were:

In both your view_i.php and view_ii.php files you are missing a required element. In addition to displaying in the browser’s toolbar, the element also is used when the page is bookmarked and in search engine results.

One other thing is that the action attribute of your form must be non-empty. The easy work around, when you are self posting, is to omit it completely:<form method="post">

While things seem to be working fine without these changes, for validation purposes, if nothing else, I would correct them.

The last thing that I noticed was that you are using md5 to hash your passwords. While this is perfectly acceptable in many situations, md5 is not nearly as secure as other options. I prefer to use something like SHA-2.

This can be implemented with something like:
[php]$password = hash(‘sha256’,$_POST[‘password’]); // heaping the password[/php]

For even more security, you can salt the hash.

Note that the hash command is not available in PHP versions below 5.1.2 (to my knowledge).

Others may have additional suggestions, but it looks pretty good to me!

^^
Okay, thanks. I added a title and deleted the “action” feature, but I think I’m still going to use md5 for now.

Sponsor our Newsletter | Privacy Policy | Terms of Service