Certainly! Below is a simple example of a license system website for scripts. This example uses HTML, CSS, and PHP (for backend logic). The system allows users to register, log in, and generate a license key for their script. The backend checks if a license is valid.
Note: This is a basic example for educational purposes. In production, you should use secure password hashing, HTTPS, prepared statements, and other security best practices.
1. index.html (Homepage)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Script License System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Script License System</h1>
<a href="register.html">Register</a> |
<a href="login.html">Login</a>
</body>
</html>
2. register.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register - Script License System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Register</h2>
<form action="register.php" method="POST">
<input type="text" name="username" placeholder="Username" required><br>
<input type="password" name="password" placeholder="Password" required><br>
<button type="submit">Register</button>
</form>
</body>
</html>
3. login.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login - Script License System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Login</h2>
<form action="login.php" method="POST">
<input type="text" name="username" placeholder="Username" required><br>
<input type="password" name="password" placeholder="Password" required><br>
<button type="submit">Login</button>
</form>
</body>
</html>
4. dashboard.php
<?php
session_start();
if (!isset($_SESSION['username'])) {
header("Location: login.html");
exit();
}
$username = $_SESSION['username'];
$license = md5($username . "SECRET_KEY"); // Simple license generation
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard - Script License System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Welcome, <?php echo htmlspecialchars($username); ?>!</h2>
<p>Your License Key:</p>
<input type="text" value="<?php echo $license; ?>" readonly style="width:300px;">
<br><br>
<a href="logout.php">Logout</a>
</body>
</html>
5. register.php
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
// Save to a simple file (use a database in production)
$users = json_decode(file_get_contents('users.json'), true) ?: [];
if (isset($users[$username])) {
echo "Username already exists.";
exit();
}
$users[$username] = password_hash($password, PASSWORD_DEFAULT);
file_put_contents('users.json', json_encode($users));
header("Location: login.html");
exit();
}
?>
6. login.php
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$users = json_decode(file_get_contents('users.json'), true) ?: [];
if (isset($users[$username]) && password_verify($password, $users[$username])) {
$_SESSION['username'] = $username;
header("Location: dashboard.php");
exit();
} else {
echo "Invalid credentials.";
exit();
}
}
?>
7. logout.php
<?php
session_start();
session_destroy();
header("Location: index.html");
exit();
?>
8. validate_license.php (API for script to check license)
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$license = $_POST['license'];
$users = json_decode(file_get_contents('users.json'), true) ?: [];
foreach ($users as $username => $hash) {
if ($license === md5($username . "SECRET_KEY")) {
echo json_encode(['valid' => true]);
exit();
}
}
echo json_encode(['valid' => false]);
exit();
}
?>
9. style.css (Simple styling)
body {
font-family: Arial, sans-serif;
margin: 40px;
background: #f4f4f4;
}
h1, h2 {
color: #333;
}
form {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
width: 300px;
}
input[type="text"], input[type="password"] {
width: 90%;
padding: 8px;
margin: 8px 0;
}
button {
padding: 8px 16px;
background: #007bff;
color: #fff;
border: none;
border-radius: 4px;
}
a {
color: #007bff;
text-decoration: none;
}
How it works
- Register: Users create an account.
- Login: Users log in to see their license key.
- Dashboard: Shows the license key (generated from username).
- License Validation: Scripts can POST to
validate_license.php to check if a license is valid.
Security Note:
This is a basic example. For real-world use, implement proper security, use a database, and secure your API endpoints.
If you need a more advanced system (with license expiration, multiple products, admin panel, etc.), let me know!