2024-07-22 15:37:47 +02:00
|
|
|
function connection(){
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
|
|
|
formData.append("username",document.getElementById("username-input").value);
|
|
|
|
formData.append("password",document.getElementById("password-input").value);
|
|
|
|
formData.append("jeton-csrf",jeton_csrf);
|
|
|
|
|
|
|
|
|
|
|
|
fetch('api.php/connection', {
|
|
|
|
method: 'POST',
|
|
|
|
body: formData
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
//console.log(data);
|
2024-08-15 23:57:12 +02:00
|
|
|
switch(data.status){
|
|
|
|
|
2024-09-09 17:43:50 +02:00
|
|
|
case "1":
|
2024-08-15 23:57:12 +02:00
|
|
|
window.location.href = "index.php";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
alert("Une erreur s'est produite lors de votre connection : "+data.msg);
|
|
|
|
break;
|
2024-07-22 15:37:47 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error:', error);
|
|
|
|
});
|
|
|
|
}
|