Initial commit
This commit is contained in:
48
contact.html
Normal file
48
contact.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<div id="contact-area">
|
||||
<div id="step1">
|
||||
<input type="email" id="email" placeholder="Votre email" required><br>
|
||||
<textarea id="message" placeholder="Votre message (10 caractères min.)"></textarea><br>
|
||||
<button onclick="sendCode()">Recevoir un code de validation</button>
|
||||
</div>
|
||||
|
||||
<div id="step2" style="display:none;">
|
||||
<p>Un code a été envoyé à votre adresse. Entrez-le ci-dessous :</p>
|
||||
<input type="text" id="verify_code" placeholder="Code à 6 chiffres">
|
||||
<button onclick="verifyAndSend()">Valider l'envoi définitif</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentToken = "";
|
||||
|
||||
async function sendCode() {
|
||||
const fd = new FormData();
|
||||
fd.append('step', 'send_code');
|
||||
fd.append('email', document.getElementById('email').value);
|
||||
fd.append('message', document.getElementById('message').value);
|
||||
|
||||
const res = await fetch('/contact-verify.php', { method: 'POST', body: fd });
|
||||
const data = await res.json();
|
||||
|
||||
if (data.status === 'success') {
|
||||
currentToken = data.token;
|
||||
document.getElementById('step1').style.display = 'none';
|
||||
document.getElementById('step2').style.display = 'block';
|
||||
} else {
|
||||
alert(data.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyAndSend() {
|
||||
const fd = new FormData();
|
||||
fd.append('step', 'verify_code');
|
||||
fd.append('token', currentToken);
|
||||
fd.append('code', document.getElementById('verify_code').value);
|
||||
|
||||
const res = await fetch('/contact-verify.php', { method: 'POST', body: fd });
|
||||
const data = await res.json();
|
||||
|
||||
alert(data.message);
|
||||
if (data.status === 'success') location.reload();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user