so i decided to brush back up on my skills in html and i wanted to create website that has a login page for members and administrators or for new members to sign up i see php is the new thing. I have created the actual homepage and the links to different pages within the websites those that i want just for members/admin. only and those everyonecan seeif you can help em i would be much abliged thanks. by the way i am doing everythign from scratch using notepad

Recommended Answers

All 5 Replies

if you really want to learn old-school coding or really want to do it from scratch, the best website where you can learn everything about php, html, javascript, etc. is at

if you really want to learn old-school coding or really want to do it from scratch, the best website where you can learn everything about php, html, javascript, etc. is at

I hope you're joking. You should read on why you should NOT use w3schools.

lol @magic media thanks..
but i truly do nto want to do it in php but if i have to then thats okay like i said I have one main website with different websites integrated in it... and i need a login and registration for the members only parts of those different webpages and I already did the websites i just need the logins for each individual one thanks

Couple of thoughts - you can do logins with different technologies - I have only really used php and mysql to do it. I fyou want registration as well, then its quite a few pages. I taught myself using a book (which was FAB and I can give you the name if you want).

Easier option might be to consider using something like joomla - all the php stuff is done already, and it handles logins and so forth. The downside of this is that if you haven't used joomla before it can be quite a steep learning curve to get to grips with if you want to make your own look and feel rather than use the provided template.

Lots to think about - depends how much time you have I reckon!

Follow this tutorial, I will use mysql as there are still so many wanna be programmers who are using it. But we will sanitize it so it will still look secured.

Let us prepare our database table.

Database name: login
Database table: member

Using phpMyAdmin, create a database called "login".

Now select the database that you have created. Click on the SQL tab and paste the following sql code.

CREATE TABLE `login`.`member` (
  `username` VARCHAR(30) NOT NULL, 
  `password` CHAR(128) NOT NULL, 
  `email` VARCHAR(50) NOT NULL, 
  `salt` CHAR(128) NOT NULL
) ENGINE = InnoDB;

Create a Registration Form called "registration.html". For the meantime let's use table for our design.

<!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form name="register" action="register.php" method="post">
    <table width="510" border="0">
            <td colspan="2"><p><strong>Registration Form</strong></p></td>
            <td><input type="text" name="username" maxlength="20" /></td>
            <td><input type="password" name="password1" /></td>
            <td>Confirm Password:</td>
            <td><input type="password" name="password2" /></td>
            <td><input type="text" name="email" id="email" /></td>
            <td><input type="submit" value="Register" /></td>

Now create registration script called "register.php".

First, let us receive the data from our registration form.

//retrieve our data from POST
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
if($password1 != $password2)
    header('Location: registration.html');
if(strlen($username) > 30)
    header('Location: registration.html');
    $hash = hash('sha256', $password1);
function createSalt()
    $text = md5(uniqid(rand(), true));
    return substr($text, 0, 3);
$salt = createSalt();
$password = hash('sha256', $salt . $hash);
$conn = mysql_connect('localhost', 'root', '');
mysql_select_db('login', $conn);
//sanitize username
$username = mysql_real_escape_string($username);
$query = "INSERT INTO member ( username, password, email, salt )
        VALUES ( '$username', '$password', '$email', '$salt' );";
header('Location: login.php');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.