├── todo app poo
├── css
│ └── style.css
├── log_out.php
├── utilities.php
├── detail.php
├── index.php
├── connect_db.php
├── checkedtodo.php
├── delete.php
├── details.phtml
├── login.phtml
├── addtodo.php
├── addtodo.phtml
├── signup.phtml
├── login.php
├── update.phtml
├── update.php
├── signup.php
├── layout.phtml
└── index.phtml
├── README.md
└── todo app oop
├── storage
└── avatars
│ ├── 18adcd60294a2d3507a83a6fd318ca47 . jpg
│ ├── 995de84728f37824bba426f6ced22c60 . jpg
│ ├── a70495ce1886833143c6e6b1590834f1 . png
│ ├── ad9244b0bdd177e487f339d2de077038 . png
│ ├── c6cb783a30426e0b0187d85505fc9a0f . png
│ ├── d094bce03a7ee7dafe06e2a6d53b6ac7 . gif
│ ├── d1a4b9ecab8a690158e83a2e393421a2 . png
│ ├── d9a5555b516d46f19168dfc5b7ad4241 . jpg
│ ├── eb401f73a4e01f9de9580137068701e7 . png
│ ├── 1a2ee428186cf3c5de0888b99373bf46 . jfif
│ ├── 5a6ad3b7bcbb912d4ed0efbf1d9b1559 . jfif
│ ├── 817d66ffd2660815a0b6889688c9afa4 . jfif
│ └── f15a3a0d033707f197efe266167b3f1c . jfif
├── detail.php
├── log_out.php
├── utilities.php
├── index.php
├── delete.php
├── checkedtodo.php
├── login.phtml
├── classes
├── database.php
├── File.php
├── user.php
└── Todo.php
├── addtodo.php
├── update.php
├── addtodo.phtml
├── update.phtml
├── signup.phtml
├── signup.php
├── details.phtml
├── login.php
├── layout.phtml
└── index.phtml
/todo app poo/css/style.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pdo-crud-php
2 |
3 | projet oop:programmation orienteés objets
4 |
5 | projet pp:programmtion proceddural
6 |
7 |
8 |
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/18adcd60294a2d3507a83a6fd318ca47 . jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/18adcd60294a2d3507a83a6fd318ca47 . jpg
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/995de84728f37824bba426f6ced22c60 . jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/995de84728f37824bba426f6ced22c60 . jpg
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/a70495ce1886833143c6e6b1590834f1 . png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/a70495ce1886833143c6e6b1590834f1 . png
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/ad9244b0bdd177e487f339d2de077038 . png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/ad9244b0bdd177e487f339d2de077038 . png
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/c6cb783a30426e0b0187d85505fc9a0f . png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/c6cb783a30426e0b0187d85505fc9a0f . png
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/d094bce03a7ee7dafe06e2a6d53b6ac7 . gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/d094bce03a7ee7dafe06e2a6d53b6ac7 . gif
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/d1a4b9ecab8a690158e83a2e393421a2 . png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/d1a4b9ecab8a690158e83a2e393421a2 . png
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/d9a5555b516d46f19168dfc5b7ad4241 . jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/d9a5555b516d46f19168dfc5b7ad4241 . jpg
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/eb401f73a4e01f9de9580137068701e7 . png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/eb401f73a4e01f9de9580137068701e7 . png
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/1a2ee428186cf3c5de0888b99373bf46 . jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/1a2ee428186cf3c5de0888b99373bf46 . jfif
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/5a6ad3b7bcbb912d4ed0efbf1d9b1559 . jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/5a6ad3b7bcbb912d4ed0efbf1d9b1559 . jfif
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/817d66ffd2660815a0b6889688c9afa4 . jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/817d66ffd2660815a0b6889688c9afa4 . jfif
--------------------------------------------------------------------------------
/todo app oop/storage/avatars/f15a3a0d033707f197efe266167b3f1c . jfif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TalelMejri/pdo-crud-php/HEAD/todo app oop/storage/avatars/f15a3a0d033707f197efe266167b3f1c . jfif
--------------------------------------------------------------------------------
/todo app oop/detail.php:
--------------------------------------------------------------------------------
1 | get($_GET['id']);
6 | $template='details';
7 | $page_titel='detail';
8 | include './layout.phtml';
9 | ?>
--------------------------------------------------------------------------------
/todo app oop/log_out.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/todo app poo/log_out.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/todo app oop/utilities.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/todo app poo/utilities.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/todo app oop/index.php:
--------------------------------------------------------------------------------
1 | getAll();
6 | $template='index';
7 | $page_titel='list_todo';
8 | include './layout.phtml';
9 | ?>
--------------------------------------------------------------------------------
/todo app oop/delete.php:
--------------------------------------------------------------------------------
1 | delete($_GET['id']);
10 | header("location:index.php?type=success&msg=delete todo succefuly");
11 | exit();
12 | ?>
--------------------------------------------------------------------------------
/todo app oop/checkedtodo.php:
--------------------------------------------------------------------------------
1 | get($_GET['id']);
10 | $todo->check($_GET['id'],!$res['complete']);
11 | header("location:index.php");
12 | exit();
13 |
14 | ?>
--------------------------------------------------------------------------------
/todo app poo/detail.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * from dsi WHERE id=?");
11 | $query->execute([$id]);
12 | $todo=$query->fetch();
13 | $page_titel="detail";
14 | $template="details";
15 | include "./layout.phtml";
16 | ?>
--------------------------------------------------------------------------------
/todo app poo/index.php:
--------------------------------------------------------------------------------
1 |
2 | prepare("SELECT * from dsi where userid=:iduser order by complete,due_date");
10 | $query->execute(['iduser'=>$_SESSION['id']]);
11 | $todos=$query->fetchall();
12 | $template="index";
13 | $page_titel="Todos";
14 | include "./layout.phtml";
15 | ?>
16 |
17 |
--------------------------------------------------------------------------------
/todo app poo/connect_db.php:
--------------------------------------------------------------------------------
1 | setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
11 | $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
12 |
13 | }catch(Exception $e){
14 | echo "ereur connected".$e;
15 | die();
16 | }
17 |
18 |
19 | ?>
--------------------------------------------------------------------------------
/todo app poo/checkedtodo.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * from dsi WHERE id=?");
9 | $sql->execute([$_GET['id']]);
10 | $todo=$sql->fetch();
11 |
12 | $query=$pdo->prepare("UPDATE dsi SET complete=:com where id=:idtodo");
13 | $query->execute(["com" => !$todo['complete'],
14 | "idtodo"=>$_GET['id']]);
15 | header("location:index.php");
16 | exit();
17 |
18 |
19 | ?>
--------------------------------------------------------------------------------
/todo app poo/delete.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * from dsi WHERE id=?");
9 | $sql->execute([$_GET['id']]);
10 | $todo=$sql->fetch();
11 | if($todo){
12 | $query=$pdo->prepare('DELETE FROM dsi where id=:todoid');
13 | $query->execute([
14 | 'todoid'=>$_GET['id']
15 | ]);
16 | }
17 | else{
18 | header("location:index.php?type=danger&msg=todo not found !");
19 | exit();
20 | }
21 | header("location:index.php?type=success&msg=delete todo succefuly");
22 | exit();
23 |
24 | ?>
--------------------------------------------------------------------------------
/todo app poo/details.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
details de = $todo['titel']; ?>
5 |
6 |
9 |
10 |
11 |
12 |
13 |
Titre
14 |
= $todo['titel'];?>
15 |
16 |
description
17 |
= $todo['description'];?>
18 |
19 |
status :=$todo['complete']?'complete':'incomplete' ?>
20 |
21 |
22 |
Date :=$todo['due_date'] ?>
23 |
24 |
25 |
--------------------------------------------------------------------------------
/todo app oop/login.phtml:
--------------------------------------------------------------------------------
1 |
2 |
23 |
--------------------------------------------------------------------------------
/todo app poo/login.phtml:
--------------------------------------------------------------------------------
1 |
2 |
23 |
--------------------------------------------------------------------------------
/todo app oop/classes/database.php:
--------------------------------------------------------------------------------
1 | setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
18 | $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
19 | $this->query('SET NAMES UTF8');
20 | }catch(Exception $e){
21 | echo 'connect failed :'.$e->getMessage();
22 | }
23 | }
24 |
25 |
26 | /**
27 | * prepare and execute a query
28 | * @param string $sql to be executed
29 | * @param array $param to be baund to the query
30 | */
31 | public function launch_query(string $sql,array $param = []):PDOStatement
32 | {
33 | $stmt=parent::prepare($sql);
34 | $stmt->execute($param);
35 | return $stmt;
36 | }
37 |
38 | }
39 |
40 |
41 |
42 | ?>
--------------------------------------------------------------------------------
/todo app oop/addtodo.php:
--------------------------------------------------------------------------------
1 | create($titel,$description,$due_date,$_SESSION['iduser']);
35 | header("location:index.php?type=success&msg=Todo added succefuly");
36 | // astuce ///
37 | //header("location:detail.php?id=".$todos);
38 | exit();
39 | }
40 | }
41 |
42 | $template="addtodo";
43 | $page_titel="addtodo";
44 | include "layout.phtml";
45 |
46 | ?>
--------------------------------------------------------------------------------
/todo app poo/addtodo.php:
--------------------------------------------------------------------------------
1 | prepare($sql);
36 | $query->execute([$titel,$description,$due_date,$_SESSION['id']]);
37 | header("location:index.php?type=success&msg=Todo added succefuly");
38 | exit();
39 | }
40 | }
41 |
42 | $template="addtodo";
43 | $page_titel="addtodo";
44 | include "layout.phtml";
45 |
46 | ?>
--------------------------------------------------------------------------------
/todo app oop/update.php:
--------------------------------------------------------------------------------
1 | update_todo($titel,$description,$due_date,$id);
36 | header("location:detail.php?id=".$id);
37 | exit();
38 | }
39 | }
40 | $todo=$todo->get(array_key_exists('id',$_GET)?$_GET['id']:$_POST['id']);
41 | if(!$todo){
42 | header("location:index.php");
43 | exit;
44 | }
45 |
46 | $template="update";
47 | $page_titel="update";
48 | include "layout.phtml";
49 | ?>
--------------------------------------------------------------------------------
/todo app oop/addtodo.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Add todo
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/todo app poo/addtodo.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Add todo
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/todo app poo/signup.phtml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/todo app poo/login.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * FROM users where email=:email");
29 | $query->execute(['email'=>$email]);
30 | $users=$query->fetch();
31 | if($users==false){
32 | $errors[0]="warning password or email";
33 | goto show_form;
34 | }else{
35 | if(password_verify($password,$users['password'])){
36 | $_SESSION['id']=$users['iduser'];
37 | $_SESSION['username']=$users['username'];
38 | $_SESSION['email']=$users['email'];
39 | $_SESSION['avatar']=$users['avatar'];
40 | header("location:./index.php");
41 | }else{
42 | $errors[0]="warning password or email";
43 | goto show_form;
44 | }
45 | }
46 | }
47 | }
48 | show_form:
49 | $template="login";
50 | $page_titel="login page";
51 | include "./layout.phtml";
52 |
53 | ?>
--------------------------------------------------------------------------------
/todo app oop/update.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Update todo
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/todo app poo/update.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Update todo
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/todo app oop/classes/File.php:
--------------------------------------------------------------------------------
1 | filename=$info_file['name'];
14 | $this->storagedirectory=$storagepath;
15 | $this->fileExtention=pathinfo($this->filename,PATHINFO_EXTENSION);
16 | $this->filesize=$info_file['size'];
17 | $this->filetmpname=$info_file['tmp_name'];
18 | }
19 |
20 | /***
21 | * return bool
22 | *
23 | */
24 | public function uploadfile():bool{
25 | $this->filename = md5(rand()). ' . ' .$this->fileExtention ;
26 | if(!move_uploaded_file($this->filetmpname,$this->storagedirectory.$this->filename)){
27 | return false;
28 | }
29 | return true;
30 | }
31 |
32 | /***
33 | * return string
34 | */
35 | public function getfilename():String{
36 | return $this->filename;
37 | }
38 |
39 | /**
40 | * return bool
41 | */
42 | public function isImage():bool{
43 | $alloewedextension=["jpg","jpeg","png","gif"];
44 | if(!in_array($this->fileExtention,$alloewedextension)){
45 | return false;
46 | }
47 | return true;
48 | }
49 |
50 | /**
51 | * return bool
52 | */
53 | public function sizefile():bool{
54 | if($this->filesize>3000000){
55 | return false;
56 | }
57 | return true;
58 | }
59 |
60 | }
61 |
62 |
63 | ?>
--------------------------------------------------------------------------------
/todo app poo/update.php:
--------------------------------------------------------------------------------
1 | prepare("UPDATE dsi SET titel=:titel,description=:description,due_date=:due_date WHERE id=:todoid");
33 | $query->execute([
34 | 'titel'=>$titel,
35 | 'description'=>$description,
36 | 'due_date'=>$due_date,
37 | 'todoid'=>array_key_exists('id',$_GET)?$_GET['id']:$_POST['id']
38 | ]);
39 |
40 | header("location:index.php");
41 | exit();
42 | }
43 | }
44 |
45 | $sql=$pdo->prepare("SELECT * from dsi WHERE id=?");
46 | $sql->execute([$_GET['id']]);
47 | $todo=$sql->fetch();
48 |
49 | if(!$todo){
50 | header("location:index.php");
51 | exit;
52 | }
53 |
54 | $template="update";
55 | $page_titel="update";
56 | include "layout.phtml";
57 | ?>
--------------------------------------------------------------------------------
/todo app oop/signup.phtml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/todo app poo/signup.php:
--------------------------------------------------------------------------------
1 | prepare($sql);
33 | $stm->execute();
34 | $touve=0;
35 | $todo=$stm->fetchall();
36 | foreach($todo as $key=>$to){
37 | if($to['username']==$username && $to['email']==$email){
38 | $trouve=1;
39 | }
40 | }
41 | if($trouve==0){
42 | $sql="INSERT INTO users (username,email,password) VALUES (:username,:email,:password)";
43 | $query=$pdo->prepare($sql);
44 | $query->execute(['username'=>$username,
45 | 'password'=>password_hash($password,PASSWORD_DEFAULT),
46 | 'email'=>$email
47 | ]);
48 | header('location:./login.php');
49 | }else{
50 | $errors[0]="déja existe";
51 | goto show_form;
52 | }
53 | }
54 | }
55 | show_form:
56 | $template="signup";
57 | $page_titel="sign up";
58 | include "./layout.phtml";
59 | ?>
--------------------------------------------------------------------------------
/todo app oop/signup.php:
--------------------------------------------------------------------------------
1 | ';
11 | print_r($_FILES);
12 | echo '';
13 | exit ;*/
14 | $file = new File('./storage/avatars/',$_FILES['avatar']);
15 |
16 | if(strlen($username)<3){
17 | $errors[0]="username must be at least 3 characters";
18 | goto show_form;
19 | }
20 | if(filter_var($email,FILTER_VALIDATE_EMAIL)==false){
21 | $errors[0]="email incorect";
22 | goto show_form;
23 | }
24 |
25 | if(strlen($password)<6){
26 | $errors[0]="password must be at least 3 characters";
27 | goto show_form;
28 | }
29 | if(strlen($confirm)<6){
30 | $errors[0]="confirm password must be at least 3 characters";
31 | goto show_form;
32 | }
33 | if($confirm!=$password){
34 | $errors[0]="confirm password must be password";
35 | goto show_form;
36 | }
37 | $upload=$file->uploadfile();
38 | if(!$upload){
39 | $errors[0]="file upload failed";
40 | goto show_form;
41 | }
42 | if($file->sizefile()==false){
43 | $errors[0]="please upload an image smaller than 1MB";
44 | goto show_form;
45 | }
46 | if($file->isImage()==false){
47 | $errors[0]="please upload an image";
48 | goto show_form;
49 | }
50 |
51 | $avatar='./storage/avatars/'.$file->getfilename();
52 | if(empty($errors)){
53 | $todo=new user();
54 | $id=$todo->signup($username,$email,$password,$avatar);
55 | if(is_int($id)){
56 | header('location:./login.php');
57 | exit;
58 | }else{
59 | $errors[0]=$id;
60 | }
61 | }
62 | }
63 | show_form:
64 | $template="signup";
65 | $page_titel="sign up";
66 | include "./layout.phtml";
67 | ?>
--------------------------------------------------------------------------------
/todo app oop/details.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
details de = $todo['titel']; ?>
5 |
6 |
9 |
10 |
11 |
12 |
13 |
Titre
14 |
= $todo['titel'];?>
15 |
16 |
description
17 |
= $todo['description'];?>
18 |
19 |
status :=$todo['complete']?'complete':'incomplete' ?>
20 |
21 |
22 |
Date :=$todo['due_date'] ?>
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
36 | =$todo['titel']?>
37 |
38 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/todo app oop/login.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * FROM users where email=:email");
31 | $query->execute(['email'=>$email]);
32 | $users=$query->fetch();
33 | if($users==false){
34 | $errors[0]="warning password or email";
35 | goto show_form;
36 | }else{
37 | if(password_verify($password,$users['password'])){
38 | $_SESSION['id']=$users['iduser'];
39 | $_SESSION['username']=$users['username'];
40 | $_SESSION['email']=$users['email'];
41 | $_SESSION['avatar']=$users['avatar'];
42 | header("location:./index.php");
43 | }else{
44 | $errors[0]="warning password or email";
45 | goto show_form;
46 | }
47 | }
48 | $user=new user();
49 | $verifier=$user->login($email,$password);
50 | if($verifier==false){
51 | $errors[0]="warning password or email";
52 | goto show_form;
53 | }else{
54 | header("location:index.php");
55 | exit;
56 | }
57 | }
58 | }
59 | show_form:
60 | $template="login";
61 | $page_titel="login page";
62 | include "./layout.phtml";
63 |
64 | ?>
--------------------------------------------------------------------------------
/todo app oop/classes/user.php:
--------------------------------------------------------------------------------
1 | pdo=new dataBase();
10 | }
11 |
12 | /***
13 | * @param String $email
14 | * @param String $password
15 | *
16 | * return Boolean
17 | */
18 | public function login(String $email,String $password):bool{
19 | $sql="SELECT * from users where email=:email";
20 | $stmt=$this->pdo->launch_query($sql,['email'=>$email]);
21 | $user=$stmt->fetch();
22 | if($user==false){
23 | return false;
24 | }else{
25 | /* if(password_verify($password,$user['password'])){
26 | $_SESSION['iduser']=$user['iduser'];
27 | $_SESSION['username']=$user['username'];
28 | $_SESSION['email']=$user['email'];
29 | $_SESSION['$password']=$user['password'];
30 | $_SESSION['avatar']=$user['avatar'];
31 | return true;
32 | }else{
33 | return false;
34 | }*/
35 | $_SESSION['iduser']=$user['iduser'];
36 | $_SESSION['username']=$user['username'];
37 | $_SESSION['email']=$user['email'];
38 | $_SESSION['$password']=$user['password'];
39 | $_SESSION['avatar']=$user['avatar'];
40 | return true;
41 | }
42 |
43 | }
44 |
45 |
46 | /***
47 | * @param String $email
48 | * @param String $password
49 | * @param String $username
50 | *
51 | * return integer
52 | */
53 |
54 | public function signup(String $username,String $email,String $password,String $avatar):int{
55 | $sql="INSERT INTO users (username,email,password,avatar) VALUES (:username,:email,:password,:avatar)";
56 | $this->pdo->launch_query($sql,[
57 | 'username'=>$username,
58 | 'email'=>$email,
59 | 'password'=>password_hash($password,PASSWORD_DEFAULT),
60 | 'avatar'=>$avatar]);
61 | return $this->pdo->lastInsertId();
62 | }
63 |
64 | }
65 |
66 |
67 | ?>
--------------------------------------------------------------------------------
/todo app oop/layout.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | =$page_titel?>
11 |
12 |
13 |
14 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/todo app poo/layout.phtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | =$page_titel?>
12 |
13 |
14 |
15 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/todo app poo/index.phtml:
--------------------------------------------------------------------------------
1 |
2 | Liste des taches
3 |
4 |
5 | =$_GET['msg']?>
6 |
7 |
8 |
9 |
10 |
11 | |
12 | titel |
13 | operation |
14 |
15 |
18 |
19 | |
20 | |
24 | = $todo['titel'] ?> |
25 |
26 |
27 |
28 |
29 | |
30 |
31 |
32 |
33 |
37 |
38 | =$todo['titel']?>
39 |
40 |
44 |
45 |
46 |
47 |
48 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/todo app oop/index.phtml:
--------------------------------------------------------------------------------
1 | Liste des taches
2 |
3 |
4 | =$_GET['msg']?>
5 |
6 |
7 |
8 |
9 |
10 | |
11 | titel |
12 | operation |
13 |
14 |
15 | no todo |
16 |
17 |
20 |
21 | |
22 | |
26 | = $todo['titel'] ?> |
27 |
28 |
29 |
30 |
31 | |
32 |
33 |
34 |
35 |
39 |
40 | =$todo['titel']?>
41 |
42 |
46 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/todo app oop/classes/Todo.php:
--------------------------------------------------------------------------------
1 |
2 | pdo = new DataBase();
11 | }
12 | /**
13 | * get all toto
14 | * retrun array $todos[]
15 | */
16 | public function getAll():array{
17 | $sql="SELECT * from dsi where userid=:userid order by complete,due_date";
18 | /* $query=$this->pdo->prepare($sql);
19 | $query->execute();*/
20 | $query=$this->pdo->launch_query($sql,['userid'=>$_SESSION['iduser']]);
21 | return $query->fetchAll();
22 | }
23 | /**
24 | * get todo with id
25 | * @param int $id
26 | * return array $todo[]
27 | */
28 | public function get($id):array
29 | {
30 | $sql='SELECT * FROM dsi where id=:id';
31 | /* $query=$this->pdo->prepare($sql);
32 | $query->execute(['id'=>$id]);*/
33 | $query=$this->pdo->launch_query($sql,['id'=>$id]);
34 | return $query->fetch();
35 | }
36 |
37 | /***
38 | * create new todo
39 | * @param string $titel
40 | * @param String $description
41 | * @param Date $due_date
42 | *
43 | * return last id created
44 | */
45 | public function create($titel,$description,$due_date,$id)
46 | {
47 | $sql="INSERT INTO dsi (titel,description,due_date,userid) VALUES (?,?,?,?)";
48 | $this->pdo->launch_query($sql,[$titel,$description,$due_date,$id]);
49 | return $this->pdo->lastInsertId();
50 | }
51 | /**
52 | * delete todo
53 | * @param int $id
54 | */
55 | public function delete($id):void
56 | {
57 | $sql="Delete from dsi where id=:id";
58 | $this->pdo->launch_query($sql,['id'=>$id]);
59 | }
60 | /**
61 | *
62 | * check todo with id
63 | * @param int $id
64 | */
65 | public function check(int $id,int $opposer_complete):void
66 | {
67 | $sql='UPDATE dsi SET complete=:com where id=:idtodo';
68 | $this->pdo->launch_query($sql,['com'=>$opposer_complete,'idtodo'=>$id]);
69 | }
70 |
71 | /**
72 | * @param string titel
73 | * @param string description
74 | * @param string due_date
75 | */
76 |
77 |
78 | public function update_todo(String $titel,String $description,String $due_date){
79 | $query="UPDATE dsi SET titel=:titel,description=:description,due_date=:due_date WHERE id=:todoid";
80 | $this->pdo->launch_query($query,[
81 | 'titel'=>$titel,
82 | 'description'=>$description,
83 | 'due_date'=>$due_date,
84 | // 'todoid'=>$id]
85 | 'todoid'=>array_key_exists('id',$_GET)?$_GET['id']:$_POST['id']]
86 | );
87 | }
88 |
89 | }
90 |
91 |
92 | ?>
--------------------------------------------------------------------------------