<?php header('Content-Type: application/json'); require_once "api.php"; session_start(); if (!empty($_POST)) { if (isset($_POST['regName']) && isset($_POST['regSurname']) && isset($_POST['regAddress']) && isset($_POST['regEmail']) && isset($_POST['regPwd']) && isset($_POST['regPwd2'])) { $name = $_POST['regName']; $surname = $_POST['regSurname']; $address = $_POST['regAddress']; $email = $_POST['regEmail']; $pwd = $_POST['regPwd']; $pwd2 = $_POST['regPwd2']; $isDataCorrect = User::userCheckForCorrectData($name, $surname, $email, $address); if ($isDataCorrect == true && $pwd == $pwd2) { $user = User::register($name, $surname, $email, $pwd, $address); $userId = $user->getUserId(); $arr = $user->getUsers($userId); } echo json_encode($arr); } if (isset($_POST['loginEmail']) && isset($_POST['loginPassword'])) { $email = $_POST['loginEmail']; $password = $_POST['loginPassword']; $user = User::login($email, $password); $userId = $user->getUserId(); $_SESSION['userId'] = $userId; } if (isset($_POST['killUser']) && $_POST['killUser'] == true) { unset($_SESSION['userId']); }
<?php require_once 'api/api.php'; session_start(); if (isset($_SESSION['user']) == true) { header('location: ./main'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // sprawdzam czy uzytkownik wpisal poprawne dane $dataCheck = User::userCheckForCorrectData($_POST['name'], $_POST['surname'], $_POST['email'], $_POST['address']); // jesli wpisal to go rejestruje i przekierowuje na strone glowna a jesli nie to wyskakuje komunikat z bledem if ($dataCheck == true) { $newUser = User::register($_POST['name'], $_POST['surname'], $_POST['email'], $_POST['password'], $_POST['password2'], $_POST['address']); if ($newUser != false) { $_SESSION['user'] = $newUser; header('location: ./main'); } } echo "Error during registration process"; } ?> <!DOCTYPE html> <html lang="pl-PL"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> <link href='https://fonts.googleapis.com/css?family=Raleway:500' rel='stylesheet' type='text/css'> <style type="text/css"> body {