Files
gravity/ปรับปรุงเว็บไซต์โรงพยาบาล/gen_pwd.php
T
2026-09-16 23:20:08 +07:00

77 lines
3.9 KiB
PHP

<?php
$password = $_POST['password'] ?? '';
$hash = '';
if ($password !== '') {
// สร้าง Hash รหัสผ่านด้วยอัลกอริทึมที่ปลอดภัยที่สุดของ PHP (Bcrypt)
$hash = password_hash($password, PASSWORD_DEFAULT);
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>เครื่องมือสร้างรหัสผ่าน (Password Hash Generator)</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Sarabun', sans-serif;
}
</style>
</head>
<body class="bg-slate-100 flex items-center justify-center h-screen p-4">
<div class="bg-white p-8 rounded-3xl shadow-xl w-full max-w-md border border-slate-100">
<div class="text-center mb-6">
<h2 class="text-2xl font-bold text-[#056839]">สร้าง Hash รหัสผ่าน</h2>
<p class="text-sm text-gray-500 mt-1">สำหรับอัปเดตข้อมูลผู้ดูแลระบบใน Database</p>
</div>
<form method="POST">
<div class="mb-4">
<label class="block text-sm font-bold text-gray-700 mb-2">กรอกรหัสผ่านที่ต้องการ</label>
<input
type="text"
name="password"
value="<?= htmlspecialchars($password) ?>"
class="w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#056839] transition-all"
placeholder="เช่น 123456"
required>
</div>
<button type="submit" class="w-full bg-[#056839] text-white py-3 rounded-xl font-bold hover:bg-[#04522b] shadow-md shadow-emerald-500/20 transition-all">
สร้าง Hash
</button>
</form>
<?php if ($hash): ?>
<div class="mt-6 p-5 bg-emerald-50 rounded-2xl border border-emerald-100 animate-[fade-in_0.3s_ease-out]">
<p class="text-sm font-bold text-[#056839] mb-2 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 mr-1" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
<polyline points="22 4 12 14.01 9 11.01"></polyline>
</svg>
ผลลัพธ์การเข้ารหัส:
</p>
<textarea
readonly
class="w-full bg-white p-3 text-sm text-gray-700 border border-emerald-200 rounded-xl break-all focus:outline-none"
rows="3"
onclick="this.select();"><?= htmlspecialchars($hash) ?></textarea>
<p class="text-[11px] text-emerald-600 mt-2 leading-relaxed">
* คัดลอกข้อความด้านบนทั้งหมด นำไปใส่ในคอลัมน์ <b>password_hash</b> ของตาราง <b>users</b> ใน phpMyAdmin ได้เลยครับ
</p>
</div>
<?php endif; ?>
<div class="mt-8 text-center border-t border-gray-100 pt-4">
<a href="admin.php" class="text-sm text-gray-500 hover:text-[#056839] transition-colors">
&larr; กลับไปหน้าเข้าสู่ระบบ (CMS)
</a>
</div>
</div>
</body>
</html>