Project · 5 files HTMLCSSJavaScriptPHPSQL / MySQL Intermediate Live preview

Login page: HTML, CSS, JavaScript, PHP and MySQL

A complete sign-in page: the form, its styling, friendly checks in the browser, secure PHP and the users table.

Updated 5 Oct 2026 134 lines 5 min read

What you will learn

  • See how the front end and back end of a login fit together
  • Check input in the browser for a better experience
  • Verify passwords safely in PHP with password_verify()
  • Store users in MySQL with a hashed password

Switch between the files with the tabs above the code. The preview runs the HTML, CSS and JavaScript; login.php and users.sql run on a web server with a database, so they are shown as code only.

Try the preview: leave a field empty, or type a short password, and press Sign in.

index.html
Download
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sign in</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="login">
    <h1>Welcome back</h1>
    <p class="sub">Sign in to continue your lessons.</p>
    <form id="loginForm" action="login.php" method="POST" novalidate>
      <label for="email">Email</label>
      <input id="email" name="email" type="email" placeholder="you@example.com" autocomplete="email">
      <label for="password">Password</label>
      <input id="password" name="password" type="password" placeholder="Your password" autocomplete="current-password">
      <p class="error" id="error" role="alert"></p>
      <button type="submit">Sign in</button>
    </form>
  </main>
  <script src="script.js"></script>
</body>
</html>
5 files · 134 lines Download all (.zip)
Not running
The preview runs the HTML, CSS and JavaScript files only. login.php, users.sql run on a server and are not executed here.
Run the preview when you are readyIt runs in an isolated sandbox with no access to this site or your account.
Make it your ownOpen the HTML, CSS and JavaScript in the Playground, change anything, and see the result instantly.
Edit in Playground

Notes

Never store plain-text passwords. password_hash() and password_verify() handle salting and hashing for you.

Related snippets

Browse CodeLab
Beginner Live preview

Professional Student Registration Portal

Build a Professional Student Registration Portal from scratch using only HTML, CSS & JavaScript. A hands-on project des…

HTMLCSSJavaScript
497 lines · 3 files View project
Beginner Live preview

A responsive profile card

Build a clean profile card with semantic HTML and a few lines of CSS.

HTML
25 lines View snippet
Hi there! đź‘‹ Have a question about the courses or joining the class? Ask me.