This is a database driven PHP template for user registration and login.

The landing page is index.php, so pointing the browser URL to the folder will open the page. Users must login to see the rest of the site. This is achieved by setting a login cookie and then checking at the beginning of each page to see whether the cookie is set. If users are not logged in, they are redirected back to the login page. The landing page after login is home.php. Each php page must be protected by having a standard spiel at the beginning of it. This is shown in tvtest.php. All HTML pages should be wrapped in a php page instead (i.e. embedded within it programmatically) as is shown in that file. Standard HTML content can then just be echoed in PHP, but only if the user is logged in.

The SQL to create the database is:

CREATE DATABASE userregistration;
GRANT ALL on userregistration.* TO 'drupal'@'localhost';
CREATE TABLE `tbl_member` (   
  `id` int(11) NOT NULL,   
  `username` varchar(255) NOT NULL,   
  `password` varchar(200) NOT NULL,   
  `email` varchar(255) NOT NULL,   
  `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `tbl_member`  ADD PRIMARY KEY (`id`);
ALTER TABLE `tbl_member`  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

You must first ensure that there is a database user called 'drupal' (no quotes) before running the above script in mysql server. The database user's password is required in the DataSource.php file within the source files (only). Table details in mysql following the above script execution as output using:

DESCRIBE userregistration;
+-----------+--------------+------+-----+---------------------+-------------------------------+
| Field     | Type         | Null | Key | Default             | Extra                         |
+-----------+--------------+------+-----+---------------------+-------------------------------+
| id        | int(11)      | NO   | PRI | NULL                | auto_increment                |
| username  | varchar(255) | NO   |     | NULL                |                               |
| password  | varchar(200) | NO   |     | NULL                |                               |
| email     | varchar(255) | NO   |     | NULL                |                               |
| create_at | timestamp    | NO   |     | current_timestamp() | on update current_timestamp() |
+-----------+--------------+------+-----+---------------------+-------------------------------+

Download the source files from here