30.01
This commit is contained in:
parent
a3d98d1256
commit
8cf30205a9
@ -5,12 +5,18 @@ require_once __DIR__ . '/auth_helper.php';
|
|||||||
$data = json_decode(file_get_contents('php://input'), true);
|
$data = json_decode(file_get_contents('php://input'), true);
|
||||||
$email = $data['email'] ?? '';
|
$email = $data['email'] ?? '';
|
||||||
$password = $data['password'] ?? '';
|
$password = $data['password'] ?? '';
|
||||||
|
$confirmPassword = $data['confirm_password'] ?? '';
|
||||||
|
|
||||||
if ($email === '' || $password === '') {
|
if ($email === '' || $password === '') {
|
||||||
echo json_encode(['success' => false, 'error' => 'Email and password are required.']);
|
echo json_encode(['success' => false, 'error' => 'Email and password are required.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($password !== $confirmPassword) {
|
||||||
|
echo json_encode(['success' => false, 'error' => 'Passwords do not match.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
echo json_encode(['success' => false, 'error' => 'Invalid email format.']);
|
echo json_encode(['success' => false, 'error' => 'Invalid email format.']);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -68,12 +68,12 @@ const app = {
|
|||||||
return { success: false, error: error.message };
|
return { success: false, error: error.message };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async register(email, password) {
|
async register(email, password, confirmPassword) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('api/register.php', {
|
const response = await fetch('api/register.php', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ email, password })
|
body: JSON.stringify({ email, password, confirm_password: confirmPassword })
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@ -594,7 +594,14 @@ const app = {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const email = registerFormLanding.querySelector('[name="email"]').value;
|
const email = registerFormLanding.querySelector('[name="email"]').value;
|
||||||
const password = registerFormLanding.querySelector('[name="password"]').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) {
|
if (result.success) {
|
||||||
registerFormLanding.reset();
|
registerFormLanding.reset();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -141,6 +141,10 @@
|
|||||||
<label class="form-label">Password</label>
|
<label class="form-label">Password</label>
|
||||||
<input type="password" class="form-control form-control-lg" name="password" placeholder="••••••••" required>
|
<input type="password" class="form-control form-control-lg" name="password" placeholder="••••••••" required>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" class="form-control form-control-lg" name="confirm_password" placeholder="••••••••" required>
|
||||||
|
</div>
|
||||||
<div class="d-grid gap-2 mb-4">
|
<div class="d-grid gap-2 mb-4">
|
||||||
<button type="submit" class="btn btn-primary btn-lg">Sign Up</button>
|
<button type="submit" class="btn btn-primary btn-lg">Sign Up</button>
|
||||||
</div>
|
</div>
|
||||||
@ -379,7 +383,7 @@
|
|||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="assets/js/main.js?v=<?php echo time(); ?>_v9"></script>
|
<script src="assets/js/main.js?v=<?php echo time(); ?>_v10"></script>
|
||||||
|
|
||||||
<!-- Confirmation Modal -->
|
<!-- Confirmation Modal -->
|
||||||
<div class="modal fade" id="confirmRemoveModal" tabindex="-1" aria-labelledby="confirmRemoveModalLabel" aria-hidden="true">
|
<div class="modal fade" id="confirmRemoveModal" tabindex="-1" aria-labelledby="confirmRemoveModalLabel" aria-hidden="true">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user