Posted about 1 year ago, by Jordan

This is an attempt to reply what was posted in the requested tutorials at Here

First of all, this tutorial is by no means COMPLETE, and will only include the parts needed to Login / Register a user successfully on a website using PHP and MySQL.

 

First of all, we need to open up a Database connection. I may note too, that this can be and i'm sure IS done in many differen't ways. However, this is how I do it.

db_info.php

This is generally the VERY first thing included on an index.php, and we do this with the include statement.

Next, we setup a basic table with PHPMyAdmin, or some other way. Or even SQL..

Now, create that table in the database with a mysql_query.

mysql_query("string above");

Great! We now have a table (Provided it all worked). Now, lets make a register page :)

I will skip the HTML part of the registration, I expect you know how to use $_POST superglobals.

register_user.php

 

Now, we've checked them out, registered them.. whats left? Oh, lets let them login!!

Again presuming you know how to make the HTML for the login form.

login_user.php

 

Of course, this is just the VERY BASIC type of user system, but this is a fully working example.

If you have any questions please leave a comment, or if you have any idea's on improving parts of the script, please also leave them in the comments :-) thanks.

 

Author Info Comment
Specific
Posted about 1 year ago.
User Avatar

Does that sql really work?  Should go like this:

Run this SQL to create your table and the script Jordan provided should work just fine =)

Thanks Jordan :P

Jordan
Posted about 1 year ago.
User Avatar

Yeah, I normally use PHPMyAdmin to create tables and stuff for me ;-).

Bit easier than doing it yourself. Thanks for the input though!

Jose
Posted about 1 year ago.
User Avatar

I was going to do the same thing Specific did and fix your table but I was too lazy. Always use the right field types with the right max chars so if someone does bypass your script check it will get stopped regardless by the mysql server.

Specific
Posted about 1 year ago.
User Avatar

I edited your post to fix the create table sql.