TKK_E32231388/login_form.php

113 lines
3.1 KiB
PHP

<?php ?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Pengering Ikan IoT</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
body { font-family: 'Poppins', sans-serif; }
</style>
</head>
<body style="
background-image: url('assets/img/bg.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
">
<body class="bg-[#f5f7fa] flex items-center justify-center min-h-screen">
<div class="bg-white/50 backdrop-blur-lg p-8 rounded-3xl shadow-2xl w-full max-w-md border border-white/20">
<h2 class="text-2xl font-bold text-center mb-6">Login</h2>
<form id="loginForm" class="space-y-4">
<div>
<label class="text-sm">Email</label>
<input name="username" type="email"
class="w-full mt-1 p-3 border rounded-xl"
placeholder="email@gmail.com" required>
</div>
<div>
<label class="text-sm">Password</label>
<input name="password" type="password"
class="w-full mt-1 p-3 border rounded-xl"
placeholder="••••••" required>
</div>
<button type="submit"
class="w-full bg-blue-500 text-white p-3 rounded-xl font-semibold">
MASUK
</button>
</form>
<p class="text-sm text-center mt-5">
Belum punya akun?
<a href="register.php" class="text-green-500 font-semibold">Daftar</a>
</p>
</div>
<!-- 🔥 FIREBASE LOGIN -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import {
getAuth,
signInWithEmailAndPassword
} from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
// 🔥 CONFIG (ISI PUNYAMU)
const firebaseConfig = {
apiKey: "AIzaSyC-Wdu6vNC0dRyF33S3_C2wpVt9I6wnp0w", // ❗ FIX (tadi double ")
authDomain: "smartoven-f9fdd.firebaseapp.com",
projectId: "smartoven-f9fdd", // 🔥 ISI BENER
appId: "1:1005261996032:web:1bcb483b922275f08f98e5"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
// 🔥 LOGIN PROCESS
const form = document.getElementById("loginForm");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const email = document.querySelector('[name="username"]').value;
const password = document.querySelector('[name="password"]').value;
try {
await signInWithEmailAndPassword(auth, email, password);
// 🔥 KIRIM KE PHP SESSION
await fetch("login_process.php", {
method: "POST",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: `email=${email}`
});
window.location.href = "dashboard.php";
} catch (err) {
alert("Login gagal: " + err.message);
}
});
</script>
</body>
</html>