Site Navigation:

Home // Tutorials // PHP // User Login

User Login - Introduction

1
I know most web sites now have features for their members. They may have email, skins of the site, members only areas, or any thing else. In this tutorial I will show you how to get skeleton of the user login working. The script will have 4 files. Two will let the user register and two will let the other two will have them log in. Before you start make sure you have mysql installed on your server. I wrote this script for PHP Version >= 4.2.0. If you are using an older version, I suggest that you download it from www.php.net. If you do not have a server of your own you can read my tutorial on this web site. Just press your browsers back button to get a list of all the php related tutorials. Click on Your Own Server.

Now that we are ready to begin. We will want to create a mysql table. We will need field for the ID#, User Name, and User Password. Here is the schema of my table:

CREATE TABLE user (
ID smallint(3) NOT NULL auto_increment,
Name varchar(30) NOT NULL default '',
Password varchar(32) NOT NULL default '',
PRIMARY KEY (ID),
UNIQUE KEY Name (Name)
)
TYPE=MyISAM;


Go ahead and create that table in what ever database you prefer. If have access to the Server, you can create the table through the MySQL command line. Next, we will make a config file for use to include in all the pages that need the database.

<?php
$User = "YourUserName";
$Pass = "YourUserPassword";
$Host = "YourDatabaseHost";
$DB = "YourMySQL Database";
$Table = "TableThatHoldsTheUserInfo";
?>


Replace the variables with there correct values and save it as common.php. This file will be included in all the pages that need to connect to the database. This is the most important file in the script. Make sure you save it as .php file, if you don't or save it as .inc or .txt or anything else, other people will be able to see your information. Once that is done, go on to the next page.

Next page »
spacer

This Tutorial was by Adman, Please post any questions in the forum. Thank you.
BACK TO TUTORIALS



Home Tutorials Free Stuff About Gallery Forum Links Contact

Copyright © Robouk 2001.

Dreamweaver®, Flash® and Photoshop® are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Hosted by Pixelcode - web design tutorials.