added stuff in pair programming session
This commit is contained in:
@@ -5,13 +5,14 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body container registerform">
|
<div class="modal-body container registerform">
|
||||||
<form>
|
<form id="marmeladenLadenRegisterForm" >
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<select name="salutation" id="salutation">
|
<select name="salutation" id="salutation">
|
||||||
<option disabled selected value="0" style="display:none">Anrede</option>
|
<option disabled selected value="0" style="display:none">Anrede</option>
|
||||||
<option value="1">Frau</option>
|
<option value="Frau">Frau</option>
|
||||||
<option value="2">Herr</option>
|
<option value="Herr">Herr</option>
|
||||||
|
<option value="Person">Person</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@@ -61,9 +62,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer d-block">
|
<div class="modal-footer d-block">
|
||||||
<button type="button" class="btn btn-secondary float-start" id="cancelButton" data-bs-target="#marmeladenladenLogin" data-bs-toggle="modal" data-bs-dismiss="modal">Cancel</button>
|
<button type="button" class="btn btn-secondary float-start" id="cancelButton" data-bs-target="#marmeladenladenLogin" data-bs-toggle="modal" data-bs-dismiss="modal">Cancel</button>
|
||||||
<button type="submit" class="btn btn-success float-end" id="registration" >Registrieren</button>
|
<button type="button" class="btn btn-success float-end" id="registration" onclick="register()" >Registrieren</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="../js/registration.js"></script>
|
||||||
8
config/dbaccess.php
Normal file
8
config/dbaccess.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$host = "localhost";
|
||||||
|
$user = "u127175db3";
|
||||||
|
$pass = "0.r8pxa1trps";
|
||||||
|
$dbname = "u127175db3";
|
||||||
|
|
||||||
|
?>
|
||||||
9
config/setupDBAccess.php
Normal file
9
config/setupDBAccess.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
//setup database access
|
||||||
|
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/dbaccess.php');
|
||||||
|
$db = new mysqli($host, $user, $pass, $dbname);
|
||||||
|
if ($db->connect_errno) {
|
||||||
|
echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
48
db/datahandler.php
Normal file
48
db/datahandler.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
include($_SERVER['DOCUMENT_ROOT'] . '/models/user.class.php');
|
||||||
|
include($_SERVER['DOCUMENT_ROOT'] . '/logic/testinput.php');
|
||||||
|
|
||||||
|
class DataHandler
|
||||||
|
{
|
||||||
|
public function registerUser($username, $password, $email, $phone, $salutation, $firstname, $lastname, $role, $street, $streetnumber, $postalcode, $country)
|
||||||
|
{
|
||||||
|
$username = testinput($username);
|
||||||
|
$password = testinput($password);
|
||||||
|
$email = testinput($email);
|
||||||
|
$phone = testinput($phone);
|
||||||
|
$salutation = testinput($salutation);
|
||||||
|
$firstname = testinput($firstname);
|
||||||
|
$lastname = testinput($lastname);
|
||||||
|
$role = testinput($role);
|
||||||
|
$street = testinput($street);
|
||||||
|
$streetnumber = testinput($streetnumber);
|
||||||
|
$postalcode = testinput($postalcode);
|
||||||
|
$country = testinput($country);
|
||||||
|
|
||||||
|
require($_SERVER['DOCUMENT_ROOT'] . '/config/setupDBAccess.php');
|
||||||
|
|
||||||
|
$sql = "INSERT INTO user (username, password, email, phone, salutation, firstname, lastname) VALUES (?,?,?,?,?,?,?)";
|
||||||
|
$sql2 = "INSERT IGNORE INTO cities (postalcode, name) VALUES (?,?)";
|
||||||
|
$sql3 = "INSERT INTO address (street, streetnumber, postalcode, country) VALUES (?,?,?,?)";
|
||||||
|
|
||||||
|
$stmtUser = $db->prepare($sql);
|
||||||
|
$stmtCities = $db->prepare($sql2);
|
||||||
|
$stmtAddress = $db->prepare($sql3);
|
||||||
|
|
||||||
|
$stmtUser->bind_param("sssssss", $username, $password, $email, $phone, $salutation, $firstname, $lastname);
|
||||||
|
$stmtCities->bind_param("ss", $postalcode, $country);
|
||||||
|
$stmtAddress->bind_param("ssss", $street, $streetnumber, $postalcode, $country);
|
||||||
|
|
||||||
|
if ($stmtUser->execute() && $stmtCities->execute() && $stmtAddress->execute()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$stmtUser->close();
|
||||||
|
$stmtCities->close();
|
||||||
|
$stmtAddress->close();
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
<script src="https://kit.fontawesome.com/7321626d2e.js" crossorigin="anonymous"></script>
|
<script src="https://kit.fontawesome.com/7321626d2e.js" crossorigin="anonymous"></script>
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||||
<script src="../js/app.js"></script>
|
<script src="../js/app.js"></script>
|
||||||
|
|
||||||
<!-- Start Footer -->
|
<!-- Start Footer -->
|
||||||
<footer class="bg-dark" id="marmeladenladen_footer">
|
<footer class="bg-dark" id="marmeladenladen_footer">
|
||||||
<!--load content with javascript-->
|
<!--load content with javascript-->
|
||||||
|
|||||||
11
js/app.js
Normal file
11
js/app.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"use strict";
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#top_nav_bar').load('../components/top_nav.html');
|
||||||
|
$('#main_nav_bar').load('../components/main_nav.html');
|
||||||
|
$('#mmlcarousel').load('../components/banner.html');
|
||||||
|
$('#mmlMainContent').load('../components/ftProducts.html');
|
||||||
|
$('#marmeladenladen_footer').load('../components/footer.html');
|
||||||
|
$('#marmeladenladen_search').load('../components/modal.html');
|
||||||
|
$('#marmeladenladenLogin').load('../components/loginModal.html');
|
||||||
|
$('#marmeladenladenRegister').load('../components/registerModal.html');
|
||||||
|
});
|
||||||
28
js/registration.js
Normal file
28
js/registration.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const email = document.getElementById('email');
|
||||||
|
const password = document.getElementById('password');
|
||||||
|
const password2 = document.getElementById('password2');
|
||||||
|
password2.addEventListener('change', checkPassword);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function register() {
|
||||||
|
if (!checkPassword()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const form = document.querySelector('#marmeladenLadenRegisterForm');
|
||||||
|
var formData = new FormData(form);
|
||||||
|
const jSONdata = JSON.stringify(Object.fromEntries(formData));
|
||||||
|
|
||||||
|
//print elements of jSONdata
|
||||||
|
console.log(jSONdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPassword() {
|
||||||
|
if (password.value != password2.value) {
|
||||||
|
password2.setCustomValidity('Passwords do not match');
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
password2.setCustomValidity('');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
10
logic/testinput.php
Normal file
10
logic/testinput.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function testinput($data) {
|
||||||
|
$data = trim($data);
|
||||||
|
$data = stripslashes($data);
|
||||||
|
$data = htmlspecialchars($data);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
45
logic/userLogic.php
Normal file
45
logic/userLogic.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
include( $_SERVER['DOCUMENT_ROOT'] . '/db/datahandler.php' );
|
||||||
|
|
||||||
|
class UserLogic
|
||||||
|
{
|
||||||
|
private $dh;
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->dh = new DataHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleUserRequests($method, $data)
|
||||||
|
{
|
||||||
|
switch ($method) {
|
||||||
|
case 'register':
|
||||||
|
return $this->dh->registerUser($data);
|
||||||
|
break;
|
||||||
|
/*
|
||||||
|
case 'login':
|
||||||
|
return $this->loginUser($data);
|
||||||
|
break;
|
||||||
|
case 'logout':
|
||||||
|
return $this->logoutUser($data);
|
||||||
|
break;
|
||||||
|
case 'getUser':
|
||||||
|
return $this->getUser($data);
|
||||||
|
break;
|
||||||
|
case 'getUsers':
|
||||||
|
return $this->getUsers($data);
|
||||||
|
break;
|
||||||
|
case 'updateUser':
|
||||||
|
return $this->updateUser($data);
|
||||||
|
break;
|
||||||
|
case 'deleteUser':
|
||||||
|
return $this->deleteUser($data);
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -6,27 +6,28 @@ class User {
|
|||||||
public $email;
|
public $email;
|
||||||
public $firstname;
|
public $firstname;
|
||||||
public $lastname;
|
public $lastname;
|
||||||
//public $role;
|
public $role;
|
||||||
//public $created_at;
|
//public $created_at;
|
||||||
public $street;
|
public $street;
|
||||||
public $streetnumber;
|
public $streetnumber;
|
||||||
public $postalcode;
|
public $postalcode;
|
||||||
public $country;
|
public $country;
|
||||||
public $phone;
|
public $phone;
|
||||||
|
public $salutation;
|
||||||
|
|
||||||
public function __construct($user_id, $username, $password, $email, $firstname, $lastname, $role, $created_at, $street, $streetnumber, $postalcode, $country, $phone) {
|
public function __construct($username, $password, $email, $phone, $salutation, $firstname, $lastname, $role, $street, $streetnumber, $postalcode, $country) {
|
||||||
$this->user_id = $user_id;
|
//$this->user_id = $user_id;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
$this->email=$email;
|
$this->email=$email;
|
||||||
$this->firstname = $firstname;
|
|
||||||
$this->lastname=$lastname;
|
|
||||||
$this->role=$role;
|
|
||||||
$this->created_at=$created_at;
|
|
||||||
$this->street = $street;
|
|
||||||
$this->streetnumber=$streetnumber;
|
|
||||||
$this->postalcode=$postalcode;
|
|
||||||
$this->country = $country;
|
|
||||||
$this->phone=$phone;
|
$this->phone=$phone;
|
||||||
|
$this->salutation=$salutation;
|
||||||
|
$this->firstname = $firstname;
|
||||||
|
$this->lastname = $lastname;
|
||||||
|
$this->role = $role;
|
||||||
|
$this->street = $street;
|
||||||
|
$this->streetnumber = $streetnumber;
|
||||||
|
$this->postalcode = $postalcode;
|
||||||
|
$this->country = $country;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user