changed a lot
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user