Hey guy's I was wondering can someone teach me how to make a Login Page and Registration page... Can someone please help me :) Also I am using a mac how would I test this? I hear use my localhost how would I do this?

Dani AI

Generated

A short, practical primer that follows the thread: a login/registration feature has two parts — the front-end (HTML/CSS layout) and the back-end (server logic + database). correctly separated design vs code; ’s link is useful for layout work but does not make a form “work” on the server side. ’s example shows a working flow, but it uses the old ext/mysql APIs and manual SHA-based salting, which are obsolete in modern PHP and carry security risks. ’s offer to help with both design and code is the right direction. (php.net)

Server-side checklist and minimal guidance:

  • Use prepared statements (PDO or mysqli) to prevent SQL injection.
  • Use PHP’s built-in password helpers — password_hash() and password_verify() — so salts and strong algorithms are handled correctly (prefer Argon2 or PASSWORD_DEFAULT where available).
  • Implement CSRF tokens for state-changing forms, regenerate the session id after login, mark session cookies Secure and HttpOnly, enforce HTTPS, and add email verification and safe password-reset flows. Refer to OWASP for authentication and password-storage best practices.

Example (concept only — adapt to framework):

// store (register)
$hash = password_hash($password, PASSWORD_DEFAULT);
$stmt = $pdo->prepare('INSERT INTO users (username, password_hash, email) VALUES (?, ?, ?)');
$stmt->execute([$username, $hash, $email]);

// verify (login)
if (password_verify($password, $row['password_hash'])) {
    session_regenerate_id(true);
    // set authenticated session state
}

See PDO prepared statements and PHP password functions for details, and the OWASP password-storage guidance for algorithm choices and parameters. (php.net)

Quick Mac testing options:

  • For simple HTML/CSS preview, opening the file in a browser is enough.
  • For PHP + database testing, use a local stack such as MAMP or XAMPP (place project files in the docroot, e.g. MAMP’s /Applications/MAMP/htdocs), or run PHP’s built-in development server from the project folder with php -S localhost:8000 (development only). Docker or tools like Valet are alternatives for more advanced workflows. (mamp.info)

Recommended Answers

All 4 Replies

By login page, do you mean the design or the code or both?

if you looking for a great resource on how to code a basic layout of a login and registration page. I followed this Webdesign.tutsplus.com it was great. The only thing it doesn't have was to turn that registration and login form to a working form where it contacts the database.

Yes I can help you in design as well as code. Tell me what kind of help do you need?

Thanks

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` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
  `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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>

<body>
<form name="register" action="register.php" method="post">
    <table width="510" border="0">
        <tr>
            <td colspan="2"><p><strong>Registration Form</strong></p></td>
        </tr>
        <tr>
            <td>Username:</td>
            <td><input type="text" name="username" maxlength="20" /></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input type="password" name="password1" /></td>
        </tr>
        <tr>
            <td>Confirm Password:</td>
            <td><input type="password" name="password2" /></td>
        </tr>
        <tr>
            <td>Email:</td>
            <td><input type="text" name="email" id="email" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" value="Register" /></td>
        </tr>
    </table>
</form>
</body>
</html>

Now create registration script called "register.php".

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

<?php
//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' );";
mysql_query($query);

mysql_close();

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.