PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- phpMyAdmin SQL Dump -- version 5.2.1 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jan 09, 2025 at 11:53 PM -- Server version: 10.4.32-MariaDB -- PHP Version: 8.0.30 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `stresswebsite` -- -- -------------------------------------------------------- -- -- Table structure for table `stress_levels` -- CREATE TABLE `stress_levels` ( `id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `stress_level` varchar(50) NOT NULL, `date` date NOT NULL, `time` time NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Dumping data for table `stress_levels` -- INSERT INTO `stress_levels` (`id`, `user_id`, `stress_level`, `date`, `time`) VALUES (1, 1, 'Low', '2025-01-07', '04:21:00'), (2, 2, 'High', '2025-01-08', '05:50:00'), (3, 1, 'Moderate', '2025-01-09', '04:59:14'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(11) NOT NULL, `name` varchar(100) NOT NULL, `matric_number` varchar(20) NOT NULL, `password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `name`, `matric_number`, `password`) VALUES (1, 'Alia', 'UDA11222', '$2y$10$lixQ1EPja0cs9CTmmYvGIerMwr8MEdPYNTK0hyIfqjHJGYD6K9kxq'), (2, 'Malik\r\n', '', ''); -- -------------------------------------------------------- -- -- Table structure for table `user_lecturers` -- CREATE TABLE `user_lecturers` ( `id` int(11) NOT NULL, `no_ic` varchar(20) NOT NULL, `password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -- -- Indexes for dumped tables -- -- -- Indexes for table `stress_levels` -- ALTER TABLE `stress_levels` ADD PRIMARY KEY (`id`), ADD KEY `user_id` (`user_id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `matric_number` (`matric_number`); -- -- Indexes for table `user_lecturers` -- ALTER TABLE `user_lecturers` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `no_ic` (`no_ic`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `stress_levels` -- ALTER TABLE `stress_levels` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `user_lecturers` -- ALTER TABLE `user_lecturers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; -- -- Constraints for dumped tables -- -- -- Constraints for table `stress_levels` -- ALTER TABLE `stress_levels` ADD CONSTRAINT `stress_levels_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`); COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Copy Clear
Copy Format Clear
<?php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Page</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .container { background: white; padding: 20px 30px; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); width: 300px; text-align: center; } .container h2 { margin-bottom: 20px; color: #00796b; } .input-field, .btn { margin: 10px 0; width: 100%; /* Ensure both fields and button are the same width */ padding: 10px; border-radius: 5px; font-size: 14px; box-sizing: border-box; /* Prevent padding from affecting width */ } .input-field { border: 1px solid #ddd; } .btn { background: #00796b; color: white; border: none; cursor: pointer; } .btn:hover { background: #004d40; } .link { margin-top: 15px; font-size: 14px; } .link a { color: #00796b; text-decoration: none; } .link a:hover { text-decoration: underline; } </style> </head> <body> <div class="container" id="loginPage"> <h2>Login</h2> <form id="loginForm"> <input type="text" class="input-field" id="matricNumber" placeholder="Enter Matric Number" required> <input type="password" class="input-field" id="password" placeholder="Enter Password" required> <select class="input-field" id="role" required> <option value="" disabled selected>Select Role</option> <option value="Student">Student</option> <option value="Lecturer">Lecturer</option> </select> <button type="button" class="btn" onclick="login()">Login</button> </form> <p class="link">Don't have an account? <a href="#" onclick="showSignUp()">Sign Up</a></p> </div> <div class="container" id="signUpPage" style="display: none;"> <h2>Sign Up</h2> <form id="signUpForm"> <input type="text" class="input-field" id="newMatricNumber" placeholder="Enter Matric Number" required> <input type="password" class="input-field" id="newPassword" placeholder="Enter Password" required> <select class="input-field" id="role" required> <option value="" disabled selected>Select Role</option> <option value="Student">Student</option> <option value="Lecturer">Lecturer</option> </select> <button type="button" class="btn" onclick="signUp()">Sign Up</button> </form> <p class="link">Already have an account? <a href="#" onclick="showLogin()">Login</a></p> </div> <script> function showSignUp() { document.getElementById('loginPage').style.display = 'none'; document.getElementById('signUpPage').style.display = 'block'; } function showLogin() { document.getElementById('signUpPage').style.display = 'none'; document.getElementById('loginPage').style.display = 'block'; } async function login() { const matricNumber = document.getElementById('matricNumber').value.trim(); const password = document.getElementById('password').value.trim(); const role = document.getElementById('role').value; // Get the selected role if (!role) { alert("Please select a role."); return; } // Make the API request with matricNumber, password, and role const response = await fetch('login.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ matricNumber, password, role }), }); const result = await response.json(); // Handle the response if (result.success) { alert(result.message); // Show success message window.location.href = result.redirect; // Redirect to the appropriate dashboard } else { alert(result.message); // Show error message } } async function signUp() { const type = document.getElementById('type').value; // 'student' or 'lecturer' const matricNumber = document.getElementById('matricNumber')?.value.trim(); const noIc = document.getElementById('no_ic')?.value.trim(); const password = document.getElementById('password').value.trim(); const payload = type === 'student' ? { matricNumber, password, type } : { no_ic: noIc, password, type }; const response = await fetch('signup.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); const result = await response.json(); alert(result.message); } </script> </body> </html>
Show:  
Copy Clear