diff --git a/src/api/products.php b/src/api/products.php index d7111af1..3456879d 100644 --- a/src/api/products.php +++ b/src/api/products.php @@ -42,6 +42,6 @@ switch ($_SERVER['REQUEST_METHOD']) { break; } -echo json_encode($response); header('Content-type: application/json; charset=utf-8'); +echo json_encode($response); die(); diff --git a/src/api/wishlists.php b/src/api/wishlists.php index b7d3dcf6..3c3a85a5 100644 --- a/src/api/wishlists.php +++ b/src/api/wishlists.php @@ -47,6 +47,6 @@ switch ($_SERVER['REQUEST_METHOD']) { break; } -echo json_encode($response); header('Content-type: application/json; charset=utf-8'); +echo json_encode($response); die(); diff --git a/src/assets/js/wishlist-view.js b/src/assets/js/wishlist-view.js index 895655fc..2cc9fc44 100644 --- a/src/assets/js/wishlist-view.js +++ b/src/assets/js/wishlist-view.js @@ -10,6 +10,7 @@ $(function() { on: 'now', onSuccess: function(response, element, xhr) { wishlists = response.results; + console.log(wishlists); element.dropdown({ values: wishlists, diff --git a/src/classes/page.php b/src/classes/page.php index 618e1467..8bd164c5 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -219,8 +219,13 @@ class Page isLoggedIn()) { - ?> + if ($user && $user->isLoggedIn()) { ?> + power) { ?> + + + Login as + + Logout diff --git a/src/classes/user.php b/src/classes/user.php index 567d1758..21f8957f 100644 --- a/src/classes/user.php +++ b/src/classes/user.php @@ -31,9 +31,10 @@ class User global $database; - $user = $database->query('SELECT * FROM `users` - WHERE `id` = ' . $this->id . ';') - ->fetch(); + $user = $database + ->query('SELECT * FROM `users` + WHERE `id` = ' . $this->id . ';') + ->fetch(); $this->power = $user['power']; } diff --git a/src/classes/wishlist.php b/src/classes/wishlist.php index e739291d..4b2fc560 100644 --- a/src/classes/wishlist.php +++ b/src/classes/wishlist.php @@ -149,6 +149,8 @@ class Wishlist + */ + +use wishthis\Page; + +$page = new Page(__FILE__, 'Login as'); + +if (isset($_POST['email'])) { + $email = $_POST['email']; + + $user = $database->query('SELECT * FROM `users` + WHERE `email` = "' . $email . '";') + ->fetch(); + + $success = false !== $user; + + if ($success) { + $_SESSION['user'] = $user; + + echo '
';
+        var_dump($user);
+        echo '
';
+    }
+}
+
+$page->header();
+$page->navigation();
+?>
+
+
+

title ?>

+ + + +
+
+
+ + +
+ + +
+
+
+
+ +footer(); diff --git a/src/pages/login.php b/src/pages/login.php index 24023789..71c9adf1 100644 --- a/src/pages/login.php +++ b/src/pages/login.php @@ -19,11 +19,10 @@ if (isset($_POST['email'], $_POST['password'])) { WHERE `email` = "' . $email . '" AND `password` = "' . $password . '" ;'); - $user = $database->query( - 'SELECT * FROM `users` - WHERE `email` = "' . $email . '" - AND `password` = "' . $password . '";' - )->fetch(); + $user = $database->query('SELECT * FROM `users` + WHERE `email` = "' . $email . '" + AND `password` = "' . $password . '";') + ->fetch(); $success = false !== $user;