| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Register</title> |
| <link rel="stylesheet" href="styles1.css"> |
| |
| |
| </head> |
| <body> |
| <div class="container"> |
| <h2>Create an Account</h2> |
| <form id="registrationForm"> |
| <input type="text" id="name" name="name" placeholder="Full Name" required> |
| <input type="email" id="email" name="email" placeholder="Email" required> |
| <input type="text" id="username" name="username" placeholder="Username" required> |
| <input type="password" id="password" name="password" placeholder="Password" required> |
| <button type="submit">Register</button> |
| </form> |
| <p>Already have an account? <a href="login.html">Login here</a></p> |
| </div> |
|
|
| <script> |
| |
| |
| function getDeviceId() { |
| let deviceId = localStorage.getItem("deviceId"); |
| if (!deviceId) { |
| |
| deviceId = 'device_' + new Date().getTime() + '_' + Math.random().toString(36).substr(2, 9); |
| |
| localStorage.setItem("deviceId", deviceId); |
| } |
| return deviceId; |
| } |
| |
| |
| document.getElementById('registrationForm').addEventListener('submit', function(event) { |
| event.preventDefault(); |
| |
| |
| const name = document.getElementById('name').value; |
| const username = document.getElementById('username').value; |
| const email = document.getElementById('email').value; |
| const password = document.getElementById('password').value; |
| const deviceId = getDeviceId(); |
| |
| |
| const registrationData = { |
| name: name, |
| email: email, |
| username: username, |
| password: password, |
| device_id: deviceId |
| }; |
| |
| |
| fetch('https://thevera-botveradb.hf.space/register_user', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify(registrationData) |
| }) |
| .then(response => response.json()) |
| .then(data => { |
| console.log("Response from server:", data); |
| alert(data.message); |
| if (data.message.includes("registered")) { |
| window.location.href = "login.html"; |
| } |
| }) |
| .catch(error => { |
| console.error('Error:', error); |
| alert('An error occurred during registration.'); |
| }); |
| }); |
| </script> |
| </body> |
| </html> |
|
|