integrated EVERYTHING!

This commit is contained in:
StockiP
2022-05-12 18:48:58 +02:00
parent 8e91e4a8f6
commit f1185ade0c
18 changed files with 424 additions and 27 deletions

37
logic/updateUserData.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
$data = json_decode(file_get_contents('php://input'));
$email = $data->username;
$phone = $data->phone;
$address = $data->street;
$name = $data->city;
$plz = $data->postalcode;
$password = $data->password;
$hashedPassword = $data->hashedPassword;
updateData($email, $phone, $address, $name, $plz, $password, $hashedPassword);
function updateData($email, $phone, $address, $name, $plz, $password, $hashedPassword){
require($_SERVER['DOCUMENT_ROOT'] . '/config/setupDBAccess.php');
if (password_verify($password, $hashedPassword)) {
$sqlOrt = "INSERT IGNORE INTO `cities` (`postalcode`, `name`) VALUES (?, ?)";
$sqlUser = "UPDATE `user` SET `phone` = ?, `address` = ?, `plz` = ? WHERE `username` = ?";
$stmtOrt = $db->prepare($sqlOrt);
$stmtUser = $db->prepare($sqlUser);
$stmtOrt->bind_param("ss", $plz, $name);
$stmtUser->bind_param("ssss", $phone, $address, $plz, $email);
if ($stmtOrt->execute() && $stmtUser->execute()) {
$response = "success";
} else {
$response = "failure";
}
$stmtOrt->close();
$stmtUser->close();
$db->close();
} else {
$response = "failure";
}
echo $response;
}