changed a lot

This commit is contained in:
StockiP
2022-05-02 12:24:22 +02:00
parent 9e28e83146
commit 8e91e4a8f6
4 changed files with 60 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
const password = document.getElementById('password');
const password2 = document.getElementById('password2');
password2.addEventListener('change', checkPassword);
const form = document.getElementById('marmeladenLadenRegisterForm');
form.addEventListener('submit', register);
@@ -15,16 +15,21 @@ async function register(event) {
//create object with form data
const data = {};
formData.forEach((value, key) => data[key] = value);
//log data on console
datastring = JSON.stringify(data);
console.log(data);
console.log(datastring);
//send data to php with Ajax
$.ajax({
url: '../logic/serviceLogic.php',
url: '../logic/registerLogic.php',
type: 'POST',
data: {method: 'register', data: data},
datatype: 'json',
data: datastring,
cache: false,
datatype: 'text',
success: function (response) {
if (response === 'success') {
window.location.replace('index.html');
console.log(response);
if (response == 'success') {
window.location.href = '../index.html';
} else {
alert(response);
}
@@ -33,8 +38,6 @@ async function register(event) {
}
}
async function checkPassword() {
if (password.value != password2.value) {
password2.setCustomValidity('Passwords do not match');