commit 6d7b483109f2e2c309d24f862181d042ca123d37
parent 5b58d5537292a9ec1e1dbff163a78b2bf7a9dab4
Author: MoiBaguette <[email protected]>
Date: Fri, 23 Jun 2023 19:53:15 +0200
templates everywhere
Diffstat:
22 files changed, 562 insertions(+), 193 deletions(-)
diff --git a/Lollipop/DatabaseObject.php b/Lollipop/DatabaseObject.php
@@ -7,21 +7,24 @@ namespace Lollipop {
{
protected string $table;
protected string $primary;
-
+ protected array $column_names;
+ protected array $not_nullable;
protected SQLDatabase $db;
protected array $data = [];
protected array $changed_keys = [];
+ private string $schema;
function __construct(SQLDatabase $db)
{
$this->db = $db;
$this->primary = $this->get_primary();
$this->table = $this->get_table();
- $this->notNullable();
+ $this->schema = $this->get_schema();
}
abstract static function get_primary(): string;
abstract static function get_table(): string;
+ abstract static function get_schema():string;
public function setData($data)
{
@@ -166,7 +169,7 @@ namespace Lollipop {
{
return $this->data;
}
- private function notNullable(){
+ public function notNullable(){
//non-auto-increment not-nullable collumn names query
$not_null = [];
$col_names = [];
@@ -189,9 +192,65 @@ namespace Lollipop {
}
$col_names[] = $tmp["column_name"];
}
- $this->data["not_nullable"] = $not_null;
- $this->data["column_names"] = $col_names;
+ $this->not_nullable = $not_null;
+ $this->column_names = $col_names;
return true;
}
+ public function get_column_names():array{
+ $column_names = [];
+ $sql = " SELECT column_name
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME = '$this->table'
+ AND TABLE_SCHEMA = '$this->schema'";
+ $stmt = $this->db->conn->prepare($sql);
+ $stmt->execute();
+ $result = $stmt->get_result();
+
+ if ($result->num_rows == 0) {
+ return [];
+ }
+ while($tmp = $result->fetch_assoc()){
+ $column_names[] = $tmp["column_name"];
+ }
+ return $column_names;
+ }
+ public function get_col_names_no_ai():array{
+ $column_names = [];
+ $sql = " SELECT column_name, extra
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME = '$this->table'
+ AND TABLE_SCHEMA = '$this->schema'
+ AND EXTRA not like '%auto_increment%'";
+ $stmt = $this->db->conn->prepare($sql);
+ $stmt->execute();
+ $result = $stmt->get_result();
+
+ if ($result->num_rows == 0) {
+ return [];
+ }
+ while($tmp = $result->fetch_assoc()){
+ $column_names[] = $tmp["column_name"];
+ }
+ return $column_names;
+ }
+ public function get_col_names_ai():array{
+ $column_names = [];
+ $sql = " SELECT column_name, extra
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_NAME = '$this->table'
+ AND TABLE_SCHEMA = '$this->schema'
+ AND EXTRA like '%auto_increment%'";
+ $stmt = $this->db->conn->prepare($sql);
+ $stmt->execute();
+ $result = $stmt->get_result();
+
+ if ($result->num_rows == 0) {
+ return [];
+ }
+ while($tmp = $result->fetch_assoc()){
+ $column_names[] = $tmp["column_name"];
+ }
+ return $column_names;
+ }
}
}
\ No newline at end of file
diff --git a/Lollipop/Utils.php b/Lollipop/Utils.php
@@ -13,25 +13,11 @@ namespace Lollipop{
$missing = [];
foreach($not_nullable as $column){
if($post[$column] == NULL || $post[$column] == ""){
- $missing[$column] = "This field cannot be empty!";
+ $key = 'missing_' . $column;
+ $missing[$key] = "This field cannot be empty!";
}
}
return $missing;
}
-
- function create_permission_radials():string{
- $db = new Lollipop\SQLDatabase("86.92.67.21", "friedel", "hailiwa", "lollipop");
- //select the available permissions from the database
- $all_p = $db->all(Permissions::class);
- $radials = "";
- foreach($all_p as $db_permission){
- $radials .= "<div class=\"mb-3 form-check\">
- <input type=\"checkbox\" class=\"form-check-input\" name=\"permissions[]\" value=" . $db_permission->id . "\">
- <input type='hidden' value='-1' name='{$db_permission->name}'>
- <label class=\"form-check-label\" for=" . $db_permission->name . ">" . $db_permission->name . "</label>
- </div> ";
- }
- return $radials;
- }
}
}
\ No newline at end of file
diff --git a/Model/Course.php b/Model/Course.php
@@ -12,5 +12,27 @@ namespace Model {
{
return "id";
}
+
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
+
+ public function add_course():bool{
+ foreach($_POST as $key => $post){
+ if(in_array($key, $this->get_col_names_no_ai())){
+ $this->{$key} = $post;
+ }
+ }
+ return $this->add();
+ }
+ public function update_course():bool{
+ foreach($_POST as $key => $post){
+ if(in_array($key, $this->get_column_names())){
+ $this->{$key} = $post;
+ }
+ }
+ return $this->save();
+ }
}
}
\ No newline at end of file
diff --git a/Model/CourseUser.php b/Model/CourseUser.php
@@ -12,5 +12,9 @@ namespace Model {
{
return "id";
}
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
}
}
\ No newline at end of file
diff --git a/Model/Exam.php b/Model/Exam.php
@@ -12,5 +12,9 @@ namespace Model {
{
return "id";
}
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
}
}
\ No newline at end of file
diff --git a/Model/Permission.php b/Model/Permission.php
@@ -12,7 +12,10 @@ namespace Model {
{
return "id";
}
-
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
function all_fields(): string{
$all_permissions = $this->db->all($this::class);
$html = "";
diff --git a/Model/PermissionUser.php b/Model/PermissionUser.php
@@ -11,10 +11,16 @@ namespace Model {
{
return 'id';
}
- public function add_permissions():array{
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
+ public function add_permissions(User $user):array{
if(array_key_exists('permissions', $_POST)){
foreach($_POST['permissions'] as $permission){
- $this->
+ $this->{$user->get_primary()} = $user->{$user->get_primary()};
+ $this->id = $permission;
+ $this->add();
}
}
return [];
diff --git a/Model/User.php b/Model/User.php
@@ -13,8 +13,13 @@ namespace Model {
}
static function get_password_field(): string{
- return "Password";
+ return "password";
}
+ static function get_schema(): string
+ {
+ return "lollipop";
+ }
+
function login_fields(): string{
$html = "";
$html .= '<input type="text" name="' . $this->get_primary(). '" placeholder="' . $this->get_primary() . '">';
@@ -30,7 +35,8 @@ namespace Model {
}else{
$html .= '<input type="text" name="' . $field . '" placeholder="' . $field . '">';
}
- if(array_key_exists($field, $res)){
+ $miss_key = 'missing_'.$field;
+ if(array_key_exists($miss_key, $res)){
$html .= '<div class="form-response"><p style="color:red;"> Field: '. $field . ' cannot be empty</p></div>';
}
}
@@ -44,7 +50,7 @@ namespace Model {
if(sizeof($missing_fields) == 0){
return $this->authenticate($post_arr);
}else{
- return $missing_fields;
+ return ["response" => "missing fields"];
}
}
function authenticate(array $post) : array
@@ -69,7 +75,6 @@ namespace Model {
private function set_globals()
//this function sets Session variables
{
- session_start();
$user_permissions = [];
//foreach field in database which is not password add to session
foreach($this->getData() as $key => $data){
@@ -83,8 +88,6 @@ namespace Model {
$user_permissions[] = $permission->id;
}
$_SESSION['user_permissions'] = $user_permissions;
-
- session_abort();
}
function add_user():array{
@@ -100,8 +103,10 @@ namespace Model {
private function add_data_db(array $post_arr): array{
$user_credentials = [];
+ $response["success"] = false;
if($this->load($post_arr[$this->get_primary()])){
- return ["response" => "<p style=\"color:red;\">this email address is already taken: {$post_arr[$this->get_primary()]} </p>"];
+ $response["response"] = "<p style=\"color:red;\">this email address is already taken: {$post_arr[$this->get_primary()]} </p>";
+ return $response;
}else{
if($post_arr[$this->get_password_field()]){
$post_arr[$this->get_password_field()] = password_hash($post_arr[$this->get_password_field()], PASSWORD_DEFAULT);
@@ -112,13 +117,14 @@ namespace Model {
$user_credentials[$col] = $post_arr[$col];
}
}
- $repsonse = [];
- $response["response"] = "<p style=\"color:green;\">succes</p>";
-
if($this->add()){
- return $user_credentials;
+ $response["response"] = "<p style=\"color:green;\">succes</p>";
+ $response += $user_credentials;
+ $response["success"] = true;
+ return $response;
}else{
- return ["repsonse" => "<p style=\"color:red;\">could not add user to database</p>"];
+ $response["response"] = "<p style=\"color:red;\">could not add user to database</p>";
+ return $response;
}
}
}
diff --git a/controller/templates.php b/controller/templates.php
@@ -0,0 +1,88 @@
+<?php
+namespace controller{
+ class templates{
+ private \Lollipop\SQLDatabase $db;
+ private \Lollipop\DatabaseObject $table;
+ private string $schema = 'lollipop';
+ private string $table_name;
+ function __construct(\Lollipop\SQLDatabase $db, \Lollipop\DatabaseObject $table){
+ $this->db = $db;
+ $this->table = $table;
+ $this->table_name = $table::class;
+ }
+
+ function form(string $action, array $data = [], array $response = []):string{
+ /*auto-increment fields are automatically hidden*/
+ $form_type = "Add";
+ $form = '<form method="POST" action="'. $action . '">';
+ foreach($this->table->get_col_names_ai() as $col){
+ if($data == []){
+ $value = '-1';
+ }else{
+ if(in_array($col , array_keys($data)))
+ $value = $data[$col];
+ $form_type = "Update";
+ }
+ $form .= '<input type="hidden" name="' . $col . '" value="' . $value . '">';
+ }
+ $form .= '<input type="hidden" name="form_type" value="' . $form_type . '">';
+ foreach($this->table->get_col_names_no_ai() as $col){
+ if($data == []){
+ $value = '';
+ }else{
+ if(in_array($col , array_keys($data)))
+ $value = $data[$col];
+ }
+ $form .= '<input type="text" name="' . $col . '" placeholder="' . $col . '" value="' . $value . '">';
+ $miss_key = 'missing_'.$col;
+ if(array_key_exists($miss_key, $response)){
+ $form .= '<div class="form-response"><p style="color:red;"> col: '. $col . ' cannot be empty</p></div>';
+ }
+ }
+ $form .='
+ <input type="submit" value="'. $form_type .'">
+ </form>';
+
+ return $form;
+ }
+
+ function search_form(string $action):string{
+ return '
+ <form method="POST" action="'. $action . '">
+ <input type="text" name="search" placeholder="Search...">
+ <input type="submit" value="Search">
+ </form>';
+ }
+
+ public function crud_table(string $action, string $search = "", string $search_key):string{
+ $search = '%' . $search . '%';
+ $table = "<table> <thead> <tr>";
+ foreach($this->table->get_column_names() as $column){
+ $table .= "<th>$column</th>";
+ }
+ $table .= "<th>Alter</th> <th>Delete</th> </tr> </thead>";
+
+ $objs = $this->db->all_where($this->table_name, [$search_key => $search]);
+ $table .= "<tbody>";
+ foreach($objs as $obj){
+ $table .= "<tr>";
+ $col_names = $obj->get_column_names();
+ foreach($col_names as $col){
+ $table .= '<td>' . $obj->{$col} . '</td>';
+ }
+ $table .= '
+ <td>
+ <a class="edit" href="' . $action . '/'. $obj->{$this->table->get_primary()} .'/edit/";>Edit</a>
+ <td>
+ <a class="delete" href="' . $action . '/'. $obj->{$this->table->get_primary()} .'/delete/">Delete</a>
+ </td>
+ </tr>';
+ }
+
+ $table .= "
+ </tbody>
+ </table>";
+ return $table;
+ }
+ }
+}
+\ No newline at end of file
diff --git a/index.php b/index.php
@@ -1,6 +1,4 @@
<?php
-use Lollipop\Utils;
-
require_once "utils/autoloader.php";
$templater = new Lollipop\Template();
$router = new Lollipop\Router($templater);
@@ -14,12 +12,13 @@ $router->addRoute(["GET"], "/", function(&$vars){
$router->addRoute(["POST"], "/", function(&$vars){
global $db;
- $vars["login-fields"] = $db->get(Model\User::class)->login_fields();
- $vars["response"] = $db->get(Model\User::class)->login();
- if($vars["response"] == []){
+ $res = $db->get(Model\User::class)->login();
+ if($res == []){
header("Location: dashboard");
exit();
}else{
+ $vars["login-fields"] = $db->get(Model\User::class)->login_fields();
+ $vars["response"] = $res["response"] ;
return "views/login.html";
}
});
@@ -38,34 +37,186 @@ $router->addRoute(["GET"], "/dashboard", function(&$vars){
return "views/dashboard.html";
});
-$router->addRoute(["GET"], "/user/add", function(&$vars){
+$router->addRoute(["GET"], "/user", function(&$vars){
global $db;
+ $user = $db->get(Model\User::class);
+ $templates = new controller\templates($db, $user);
- $vars["user-data-fields"] = $db->get(Model\User::class)->all_fields();
- $vars["permission-fields"] = $db->get(Model\Permission::class)->all_fields();
- return "views/add_user.html";
+ if(isset($_POST["search"])){
+ $user->load($_POST["search"]);
+ $data = $user->getData();
+ }
+ $vars["form"] = $templates->form("/user");
+ $vars["search"] = $templates->search_form("/user/search");
+ $vars["table"] = $templates->crud_table("/user", "" ,"email");
+ return "views/user.html";
});
-$router->addRoute(["POST"], "/user/add", function(&$vars){
+$router->addRoute(["GET"], "/user/search/:search_query", function(&$vars){
global $db;
$user = $db->get(Model\User::class);
- $permission = $db->get(Model\Permission::class);
- $permission_user = $db->get(Model\PermissionUser::class);
-
- $res = $user->add_user();
- $permission_user->add_permissions();
- $vars["user-data-fields"] = $user->all_fields($res);
- $vars["permission-fields"] = $permission->all_fields();
- if(array_key_exists("succes", $res)){
- $vars["succes"] = $res["succes"];
+ $templates = new controller\templates($db, $user);
+ $vars["form"] = $templates->form("/user");
+ $vars["search"] = $templates->search_form("/user/search");
+ $vars["table"] = $templates->crud_table("/user", $vars["search_query"], "email");
+ return "views/user.html";
+});
+
+$router->addRoute(["POST"], "/user/search", function(&$vars){
+ if(isset($_POST['search'])){
+ if($_POST['search'] == ""){
+ $search = "%";
+ }else{
+ $search = $_POST['search'];
+ }
+ $header = '/user/search/' . $search;
+ header('Location: ' . $header);
+ }else{
+ echo "wtF?";
+ var_dump($_POST);
}
- return "views/add_user.html";
});
+$router->addRoute(["GET"], "/user/:primary_key/edit", function(&$vars){
+ global $db;
+ $user = $db->get(Model\User::class);
+ $templates = new controller\templates($db, $user);
+ $data = [];
+ $user->load($vars["primary_key"]);
+ foreach($user->getData() as $key => $col){
+ $data[$key] = $col;
+ }
+ $vars["form"] = $templates->form("/user", $data);
+ $vars["search"] = $templates->search_form("/user/search");
+ $vars["table"] = $templates->crud_table("/user", "", "email");
+ return "views/user.html";
+});
+
+$router->addRoute(["GET"], "/user/:primary_key/delete", function(&$vars){
+ global $db;
+ $user = $db->get(Model\User::class);
+ $templates = new controller\templates($db, $user);
+ $user->load($vars["primary_key"]);
+ $user->delete();
+ $vars["form"] = $templates->form("/user");
+ $vars["search"] = $templates->search_form("/user");
+ $vars["table"] = $templates->crud_table("/user" ,"", "email");
+ return "views/user.html";
+});
+
+$router->addRoute(["POST"], "/user", function(&$vars){
+ global $db;
+ $user = $db->get(Model\User::class);
+ $templates = new controller\templates($db, $user);
+ $data = [];
+
+ if(isset($_POST["form_type"])){
+ if($_POST["form_type"] == 'Add')
+ $user->add_user();
+ elseif($_POST["form_type"] == 'Update'){
+ $user->update_user();
+ }
+ }
+
+ $vars["form"] = $templates->form("/user", $data);
+ $vars["search"] = $templates->search_form("/user");
+ $vars["table"] = $templates->crud_table("/user", "", "email");
+ return "views/user.html";
+});
+
+
$router->addRoute(["POST"], "/logout", function(&$vars){
session_unset();
session_destroy();
header("Location: /");
});
+$router->addRoute(["GET"], "/course", function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $templates = new controller\templates($db, $course);
+
+ if(isset($_POST["search"])){
+ $course->load($_POST["search"]);
+ $data = $course->getData();
+ }
+ $vars["form"] = $templates->form("/course");
+ $vars["search"] = $templates->search_form("/course/search");
+ $vars["table"] = $templates->crud_table("/course", "" ,"name");
+ return "views/course.html";
+});
+
+$router->addRoute(["GET"], "/course/search/:search_query", function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $templates = new controller\templates($db, $course);
+ $vars["form"] = $templates->form("/course");
+ $vars["search"] = $templates->search_form("/course/search");
+ $vars["table"] = $templates->crud_table("/course", $vars["search_query"], "name");
+ return "views/course.html";
+});
+
+$router->addRoute(["POST"], "/course/search", function(&$vars){
+ if(isset($_POST['search'])){
+ if($_POST['search'] == ""){
+ $search = "%";
+ }else{
+ $search = $_POST['search'];
+ }
+ $header = '/course/search/' . $search;
+ header('Location: ' . $header);
+ }else{
+ echo "wtF?";
+ var_dump($_POST);
+ }
+});
+
+$router->addRoute(["GET"], "/course/:primary_key/edit", function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $templates = new controller\templates($db, $course);
+ $data = [];
+ $course->load($vars["primary_key"]);
+ foreach($course->getData() as $key => $col){
+ $data[$key] = $col;
+ }
+ $vars["form"] = $templates->form("/course", $data);
+ $vars["search"] = $templates->search_form("/course/search");
+ $vars["table"] = $templates->crud_table("/course", "", "name");
+ return "views/course.html";
+});
+
+$router->addRoute(["GET"], "/course/:primary_key/delete", function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $templates = new controller\templates($db, $course);
+ $course->load($vars["primary_key"]);
+ $course->delete();
+ $vars["form"] = $templates->form("/course");
+ $vars["search"] = $templates->search_form("/course");
+ $vars["table"] = $templates->crud_table("/course" ,"", "name");
+ return "views/course.html";
+});
+
+$router->addRoute(["POST"], "/course", function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $templates = new controller\templates($db, $course);
+ $data = [];
+
+ if(isset($_POST["form_type"])){
+ if($_POST["form_type"] == 'Add')
+ $course->add_course();
+ elseif($_POST["form_type"] == 'Update'){
+ $course->update_course();
+ }
+ }
+
+ $vars["form"] = $templates->form("/course", $data);
+ $vars["search"] = $templates->search_form("/course");
+ $vars["table"] = $templates->crud_table("/course", "", "name");
+ return "views/course.html";
+});
+
+
$router->route();
diff --git a/views/add_user.html b/views/add_user.html
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html lang="eng">
- <title>Add User</title>
- <link rel="stylesheet" href="/views/css/add_user.css">
- <link rel="stylesheet" href="/views/css/input.css">
- <meta name="viewport" content="width=device-width, initial-scale=1" />
-</head>
-<body>
- <div class="header">
- <h1>Lollipop</h1>
- </div>
- <div class="flex-row">
- <div class="flex-side"></div>
-
- <div class="flex-middle">
- <div class="form-title"><h2>Enter credentials:</h1></div>
- <form method="POST" action="/user/add">
- {{$user-data-fields}}
- {{$permission-fields}}
- <input type="submit" value="Submit">
- {{$response}}
- </form>
- </div>
-
- <div class="flex-side"></div>
- </div>
-</body>
-</html>
-\ No newline at end of file
diff --git a/views/course.html b/views/course.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="eng">
+ <title>Add User</title>
+ <link rel="stylesheet" href="/views/css/theme.css">
+ <link rel="stylesheet" href="/views/css/form_template.css">
+ <link rel="stylesheet" href="/views/css/course.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+</head>
+<body>
+ <div class="flex_container">
+ <div class ="side_bar">
+ <div class ="form_add">
+ <h1>Add Course</h1>
+ <a href="/course">New</a>
+ {{$form}}
+ </div>
+ </div>
+ <div class = "courses">
+ <div class="search">
+ {{$search}}
+ </div>
+ <div class ="table">
+ {{$table}}
+ </div>
+ </div>
+
+ </div>
+</body>
+</html>
+\ No newline at end of file
diff --git a/views/crud_user.php b/views/crud_user.php
@@ -113,15 +113,7 @@ if (!isset($_SESSION['email'])) {
$u = $db->get(Model\User::class);
- $data = array('email' => $email, 'fname' => $fname, 'lname' => $lname, 'pwd' => $hashed_pwd);
-
- $u->setData($data);
- $bool = $u->insert();
- if (!$bool) {
- echo "user already exists";
- } else {
- echo "succes!";
- }
+
}
}
?>
diff --git a/views/css/add_user.css b/views/css/add_user.css
@@ -1,46 +1,23 @@
-* {
- box-sizing: border-box;
- font-family: Verdana,sans-serif;
- font-size: 15px;
- line-height: 1.5;
-
- }
-
- body{
- padding: 0;
- margin: 0;
- background: #1abc9c;
- }
-
- .header{
- padding: 40px;
- background: #1abc9c;
- text-align: center;
- }
-
- h1{
- color: white;
- font-size: 50px;
- }
- .flex-row{
- display: flex;
- align-items: stretch;
- }
-
- .flex-middle{
- margin:1em;
- padding: 25px;
- flex-grow: 8;
- max-width:350px;
- background-color: #f1f1f1;
- border-radius: 35px;
- }
-
- .flex-side{
- flex-grow: 1;
- }
-
- .form-label{
- position: center;
- }
-
-\ No newline at end of file
+.header{
+ padding: 40px;
+ text-align: center;
+}
+
+.flex-row{
+ display: flex;
+ align-items: stretch;
+}
+
+.flex-middle{
+ margin:1em;
+ padding: 25px;
+ flex-grow: 8;
+ max-width:350px;
+ background-color: #f1f1f1;
+ border-radius: 35px;
+}
+
+.flex-side{
+ flex-grow: 1;
+}
+
diff --git a/views/css/course.css b/views/css/course.css
@@ -0,0 +1,32 @@
+.flex_container{
+ display: flex;
+ align-items: stretch;
+}
+.courses{
+ flex-grow: 8;
+ margin: 25px;
+ padding: 25px;
+ flex-grow: 1;
+ border-radius: 35px;
+ background-color: #f1f1f1;
+}
+.side_bar{
+ flex-grow: 1;
+ max-width:350px;
+ margin: 25px;
+ border-radius: 35px;
+ background-color: #f1f1f1;
+}
+.form_add{
+ padding: 25px;
+}
+.search form{
+ display:flex;
+}
+.search form input[type=text]{
+ margin-right: 5px;
+}
+.search form input[type=submit]{
+
+ width: fit-content;
+ }
+\ No newline at end of file
diff --git a/views/css/form_template.css b/views/css/form_template.css
@@ -0,0 +1,38 @@
+.form_card{
+ margin:1em;
+ padding: 25px;
+ border-radius: 35px;
+ background-color: #f1f1f1;
+}
+
+.form_card h1{
+ font-size: 25px;
+ width: 100%;
+ text-align: center;
+}
+
+input[type=text], input[type=password]{
+ width: 100%;
+ padding: 6px 12px;
+ margin: 8px 0;
+ border-radius: 4px;
+ border: 3px solid #ccc;
+ outline: none;
+}
+
+input[type=password]:focus, input[type=text]:focus{
+ border: 3px solid #555;
+}
+
+input[type=button], input[type=submit], input[type=reset]{
+ width: 80%;
+ padding: 6px 12px;
+ margin: 8px 0;
+}
+
+.form-response{
+ width: 100%;
+ text-align: center;
+ margin-bottom: 5px;
+}
+
diff --git a/views/css/input.css b/views/css/input.css
@@ -1,35 +0,0 @@
-.form-title{
- width: 100%;
- text-align: center;
-}
-
-h2{
- font-size: 25px;
-}
-
-input[type=text], input[type=password]{
- width: 100%;
- padding: 6px 12px;
- margin: 8px 0;
- border-radius: 4px;
- border: 3px solid #ccc;
- outline: none;
-}
-
-input[type=password]:focus, input[type=text]:focus{
- border: 3px solid #555;
-}
-
-input[type=button], input[type=submit], input[type=reset]{
- width: 80%;
- margin-left:10%;
- margin-top:5px;
- padding: 4px 8px;
-}
-
-.form-response{
- width: 100%;
- text-align: center;
- margin-bottom: 5px;
-}
-
diff --git a/views/css/login.css b/views/css/login.css
@@ -6,21 +6,11 @@
}
-body{
- padding: 0;
- margin: 0;
- background: #1abc9c;
-}
-
.header{
padding: 40px;
background: #1abc9c;
- text-align: center;
-}
-
-h1{
color: white;
- font-size: 50px;
+ text-align: center;
}
.flex-row{
@@ -33,8 +23,8 @@ h1{
padding: 25px;
flex-grow: 8;
max-width:350px;
- background-color: #f1f1f1;
border-radius: 35px;
+ background-color: #f1f1f1;
}
.flex-side{
diff --git a/views/css/theme.css b/views/css/theme.css
@@ -0,0 +1,11 @@
+*{
+ box-sizing: border-box;
+ font-family: Verdana,sans-serif;
+ font-size: 15px;
+ line-height: 1.5;
+}
+body{
+ padding: 0;
+ margin: 0;
+ background: #1abc9c;
+}
diff --git a/views/dashboard.html b/views/dashboard.html
@@ -3,9 +3,14 @@
<link rel="stylesheet" href="views/css/input.css">
</head>
<body>
- <form method="post" action="/logout">
- <input type="submit" value="Logout">
- </form>
+ <div class="header">
+ <div></div>
+ <h1>Lollipop</h1>
+ <form method="post" action="/logout">
+ <input type="submit" value="Logout">
+ </form>
+ </div>
+
{{$email}}
</body>
</html>
\ No newline at end of file
diff --git a/views/search_user.php b/views/search_user.php
@@ -49,8 +49,7 @@ if (isset($_GET['query'])) {
<th>Email</th>
<th>First Name</th>
<th>Last Name</th>
- <th>Alter</th>
- <th>Delete</th>
+
</tr>
</thead>
<tbody>
diff --git a/views/user.html b/views/user.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="eng">
+ <title>Add User</title>
+ <link rel="stylesheet" href="/views/css/theme.css">
+ <link rel="stylesheet" href="/views/css/form_template.css">
+ <link rel="stylesheet" href="/views/css/course.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+</head>
+<body>
+ <div class="flex_container">
+ <div class ="side_bar">
+ <div class ="form_add">
+ <h1>Add Course</h1>
+ <a href="/course">New</a>
+ {{$form}}
+ </div>
+ </div>
+ <div class = "courses">
+ <div class="search">
+ {{$search}}
+ </div>
+ <div class ="table">
+ {{$table}}
+ </div>
+ </div>
+ </div>
+</body>
+</html>
+\ No newline at end of file