integrated EVERYTHING!
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
include($_SERVER['DOCUMENT_ROOT'] . '/models/user.class.php');
|
||||
include($_SERVER['DOCUMENT_ROOT'] . '/logic/testinput.php');
|
||||
|
||||
class DataHandler
|
||||
@@ -7,7 +6,7 @@ class DataHandler
|
||||
public function registerUser($data)
|
||||
{
|
||||
$username = testinput($data->email);
|
||||
$password = testinput($data->password);
|
||||
$password = password_hash(testinput($data->password), PASSWORD_DEFAULT);
|
||||
$email = testinput($data->email);
|
||||
$phone = testinput($data->phone);
|
||||
$salutation = testinput($data->salutation);
|
||||
@@ -15,10 +14,9 @@ class DataHandler
|
||||
$lastname = testinput($data->lastname);
|
||||
$street = testinput($data->street);
|
||||
$postalcode = testinput($data->postalcode);
|
||||
$city = testinput($data->city);
|
||||
$role = "customer";
|
||||
|
||||
$password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
require($_SERVER['DOCUMENT_ROOT'] . '/config/setupDBAccess.php');
|
||||
|
||||
$sql2 = "INSERT IGNORE INTO `cities` (`city_id`, `postalcode`, `name`) VALUES (?,?,?)";
|
||||
@@ -29,17 +27,21 @@ class DataHandler
|
||||
$stmtCities = $db->prepare($sql2);
|
||||
|
||||
$stmtUser->bind_param("ssssssssss", null, $username, $password, $email, $phone, $salutation, $firstname, $lastname, $street, $postalcode, $role, null);
|
||||
$stmtCities->bind_param("sss", null, $postalcode, $coty);
|
||||
$stmtCities->bind_param("sss", null, $postalcode, $city);
|
||||
|
||||
if ($stmtUser->execute() && $stmtCities->execute() && $stmtAddress->execute()) {
|
||||
return $data;
|
||||
if ($stmtUser->execute() && $stmtCities->execute()) {
|
||||
echo "Your registration was successfully.\n";
|
||||
$returnArray['Response'] = "Your registration was successfully.";
|
||||
} else {
|
||||
return false;
|
||||
echo "Your registration was not successfully. Please try again later.\n";
|
||||
$returnArray['Response'] = "Your registration was not successfully. Please try again later.";
|
||||
}
|
||||
$stmtUser->close();
|
||||
$stmtCities->close();
|
||||
$stmtAddress->close();
|
||||
$db->close();
|
||||
|
||||
return $returnArray;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user