From 8cf30205a9059e8806589c4dc0c9c7f0458f38d0 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 1 Feb 2026 18:27:00 +0000 Subject: [PATCH] 30.01 --- api/register.php | 6 ++++++ assets/js/main.js | 13 ++++++++++--- index.php | 6 +++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/api/register.php b/api/register.php index b8256aa..37bf626 100644 --- a/api/register.php +++ b/api/register.php @@ -5,12 +5,18 @@ require_once __DIR__ . '/auth_helper.php'; $data = json_decode(file_get_contents('php://input'), true); $email = $data['email'] ?? ''; $password = $data['password'] ?? ''; +$confirmPassword = $data['confirm_password'] ?? ''; if ($email === '' || $password === '') { echo json_encode(['success' => false, 'error' => 'Email and password are required.']); exit; } +if ($password !== $confirmPassword) { + echo json_encode(['success' => false, 'error' => 'Passwords do not match.']); + exit; +} + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo json_encode(['success' => false, 'error' => 'Invalid email format.']); exit; diff --git a/assets/js/main.js b/assets/js/main.js index 6979fc3..e579970 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -68,12 +68,12 @@ const app = { return { success: false, error: error.message }; } }, - async register(email, password) { + async register(email, password, confirmPassword) { try { const response = await fetch('api/register.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email, password }) + body: JSON.stringify({ email, password, confirm_password: confirmPassword }) }); const data = await response.json(); if (data.success) { @@ -594,7 +594,14 @@ const app = { e.preventDefault(); const email = registerFormLanding.querySelector('[name="email"]').value; const password = registerFormLanding.querySelector('[name="password"]').value; - const result = await app.api.register(email, password); + const confirmPassword = registerFormLanding.querySelector('[name="confirm_password"]').value; + + if (password !== confirmPassword) { + alert('Passwords do not match.'); + return; + } + + const result = await app.api.register(email, password, confirmPassword); if (result.success) { registerFormLanding.reset(); } else { diff --git a/index.php b/index.php index f415eac..74fa6b8 100644 --- a/index.php +++ b/index.php @@ -141,6 +141,10 @@ +
+ + +
@@ -379,7 +383,7 @@ - +