├── images ├── slider │ ├── slide1.jpg │ ├── slide2.jpg │ └── slide3.jpg ├── profilepicture │ ├── demoProfile.png │ ├── 6633cef0283d68.31351445.png │ └── 6739c4a889c544.00987571.jpg └── blog │ ├── 664f7f40d93d96.95624964.jpg │ ├── 664f7f57a37010.29027527.png │ ├── 664f7f6a110ea5.54405445.jpg │ ├── 664f7f88320f21.86539797.jpg │ ├── 664f7fa77f1b63.26150100.jpg │ ├── 664f7fda54aeb4.94234836.jpg │ ├── 6661ecf4cb5ae0.81626356.jpg │ ├── 6661ed36c5acb2.33517949.jpg │ ├── 6661ed62c5e185.71130696.jpg │ ├── 6739c6c885cbe5.59970848.jpg │ └── 6739c71b3ec639.41157608.jpg ├── signout.php ├── components ├── homeComponents │ └── slider │ │ ├── slider.css │ │ └── slider.php └── adminSidebar.php ├── footer.php ├── about.php ├── contact.php ├── search.php ├── assets ├── style.min.css.map ├── style.min.css └── style.scss ├── dashboard.php ├── classes ├── db.php └── signup.php ├── index.php ├── single-post.php ├── delete-post.php ├── header.php ├── signin.php ├── blog.php ├── add-new-post.php ├── change-password.php ├── profile-picture.php ├── update-profile.php ├── navbar.php ├── edit-post.php ├── signup.php ├── all-post.php ├── category.php └── cmbd234.sql /images/slider/slide1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asif-daffodil/blog/HEAD/images/slider/slide1.jpg -------------------------------------------------------------------------------- /images/slider/slide2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asif-daffodil/blog/HEAD/images/slider/slide2.jpg -------------------------------------------------------------------------------- /images/slider/slide3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asif-daffodil/blog/HEAD/images/slider/slide3.jpg -------------------------------------------------------------------------------- /signout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /about.php: -------------------------------------------------------------------------------- 1 | 4 |
5 |
6 |
7 |

About Page

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /contact.php: -------------------------------------------------------------------------------- 1 | 4 |
5 |
6 |
7 |

Contact Page

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /search.php: -------------------------------------------------------------------------------- 1 | 4 |
5 |
6 |
7 |

Search Page

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /assets/style.min.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["style.scss"],"names":[],"mappings":"AAGa,yBACG,qBAAA,CAOhB,UACI,iBAAA,CACA,gBACI,eAAA,CAEJ,mBACI,iBAAA,CACA,KAAA,CACA,SAAA,CACA,eAAA,CACA,YAAA,CACA,eAAA,CACA,eAAA,CACA,WAAA,CACA,WAAA,CACA,sBACI,gBAAA,CACA,UAAA,CACA,wBACI,UAAA,CACA,oBAAA,CACA,aAAA,CAEJ,4BACI,kBAAA,CAKR,yBACI,aAAA","file":"style.min.css"} -------------------------------------------------------------------------------- /dashboard.php: -------------------------------------------------------------------------------- 1 | 4 |
5 |
6 |
7 | 8 |
9 |
10 | Dashboard 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /assets/style.min.css: -------------------------------------------------------------------------------- 1 | .adminSidebar>li:hover>a{color:#fff !important}.nav-item{position:relative}.nav-item:hover{background:#333}.nav-item>.subMenu{position:absolute;top:0;left:100%;background:#333;display:none;min-width:180px;list-style:none;padding:0px;z-index:200}.nav-item>.subMenu>li{padding:6px 10px;width:100%}.nav-item>.subMenu>li>a{color:#fff;text-decoration:none;display:block}.nav-item>.subMenu>li:hover{background:#212529}.nav-item:hover .subMenu{display:block}/*# sourceMappingURL=style.min.css.map */ -------------------------------------------------------------------------------- /classes/db.php: -------------------------------------------------------------------------------- 1 | conn = mysqli_connect($this::host, $this::user, $this::password, $this::dbName); 16 | } 17 | 18 | public function __destruct() 19 | { 20 | unset($this->conn); 21 | } 22 | 23 | public function sanitize($data) 24 | { 25 | $data = trim($data); 26 | $data = stripslashes($data); 27 | $data = htmlspecialchars($data); 28 | return $data; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/adminSidebar.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/style.scss: -------------------------------------------------------------------------------- 1 | .adminSidebar{ 2 | >li{ 3 | &:hover{ 4 | >a{ 5 | color: #fff !important; 6 | } 7 | } 8 | 9 | } 10 | } 11 | 12 | .nav-item{ 13 | position: relative; 14 | &:hover{ 15 | background: #333; 16 | } 17 | >.subMenu{ 18 | position: absolute; 19 | top: 0; 20 | left: 100%; 21 | background: #333; 22 | display: none; 23 | min-width: 180px; 24 | list-style: none; 25 | padding: 0px; 26 | z-index: 200; 27 | >li{ 28 | padding: 6px 10px; 29 | width: 100%; 30 | >a{ 31 | color: #fff; 32 | text-decoration: none; 33 | display: block; 34 | } 35 | &:hover{ 36 | background: #212529; 37 | } 38 | } 39 | } 40 | &:hover{ 41 | .subMenu{ 42 | display: block; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM posts ORDER BY id DESC LIMIT 3"); 6 | // conver into Associative array 7 | $posts = $getPost->fetch_all(MYSQLI_ASSOC); 8 | ?> 9 |
10 |
11 |
12 |

Latest Post

13 |
14 | 17 |
18 |
19 | <?= $post['title'] ?> 20 |
21 |
22 |

...

23 | Read More 24 |
25 |
26 |
27 | 28 |
29 |
30 | -------------------------------------------------------------------------------- /single-post.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM posts WHERE id='$pid'"); 5 | $post = $getPost->num_rows > 0 ? $getPost->fetch_object() : header("location: ./blog.php"); 6 | 7 | // get 4 random post 8 | $getPost = $conn->query("SELECT * FROM posts ORDER BY RAND() LIMIT 4"); 9 | $randomPosts = $getPost->fetch_all(MYSQLI_ASSOC); 10 | ?> 11 |
12 |
13 |
14 | <?= $post->title ?> 15 |
16 |
17 |

title ?>

18 |

details ?>

19 |
20 |
21 |

Random Posts

22 | 23 |
24 | <?= $rPost['title'] ?> 25 |
26 |
27 | Read More 28 |
29 |
30 | 31 |
32 |
33 |
34 | -------------------------------------------------------------------------------- /delete-post.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM posts WHERE id='$id'"); 9 | $post = $getPost->num_rows > 0 ? $getPost->fetch_object() : header("location: ./all-post.php"); 10 | 11 | if (isset($_POST['delete-post'])) { 12 | $img = $post->img; 13 | if (!empty($img)) { 14 | unlink("./images/blog/$img"); 15 | } 16 | $deletePost = $conn->query("DELETE FROM posts WHERE id='$id'"); 17 | if ($deletePost) { 18 | echo ""; 19 | echo ""; 20 | } else { 21 | echo ""; 22 | } 23 | } 24 | 25 | ?> 26 |
27 |
28 |
29 | 30 |
31 |
32 |

Delete Post

33 |

34 | Do you realy want to delete the post? 35 |

36 |
37 | 38 |
39 | No 40 |
41 |
42 |
-------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM users WHERE email='$email'"); 12 | $userInfo = $getUserInfo->fetch_object(); 13 | } 14 | 15 | udata(); 16 | 17 | $pageName = basename($_SERVER['PHP_SELF']); 18 | 19 | ?> 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Bootstrap demo 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /signin.php: -------------------------------------------------------------------------------- 1 | query($sql); 12 | if ($checkEmail->num_rows > 0) { 13 | $row = $checkEmail->fetch_object(); 14 | if (password_verify($password, $row->password)) { 15 | $_SESSION['email'] = $uemail; 16 | $_SESSION['name'] = $row->name; 17 | $_SESSION['img'] = $row->img; 18 | $_SESSION['role'] = $row->role; 19 | echo ""; 20 | } else { 21 | echo ""; 22 | } 23 | } 24 | } 25 | 26 | 27 | ?> 28 |
29 |
30 |
31 |

Sign In

32 |
33 |
34 | 35 |
36 |
37 | 38 |
39 |
40 | 41 |
42 |
43 |
44 |
45 |
46 | -------------------------------------------------------------------------------- /components/homeComponents/slider/slider.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /blog.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM posts"); 5 | $totalPost = $selectQyery->num_rows; 6 | $limitPerPage = 6; 7 | $totalPage = ceil($totalPost / $limitPerPage); 8 | $offset = ($pageno - 1) * $limitPerPage; 9 | $getPost = $conn->query("SELECT * FROM posts ORDER BY id DESC LIMIT $offset, $limitPerPage"); 10 | $posts = $getPost->fetch_all(MYSQLI_ASSOC); 11 | ?> 12 |
13 |
14 |
15 |

Blog Page

16 |
17 | 18 |
19 |
20 | <?= $post['title'] ?> 21 |
22 |
23 |

...

24 | Read More 25 |
26 |
27 |
28 | 29 |
30 |
31 |
32 | 47 |
48 |
49 | -------------------------------------------------------------------------------- /add-new-post.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM categories"); 5 | $allCats = $allCat->fetch_all(MYSQLI_ASSOC); 6 | ?> 7 |
8 |
9 |
10 | 11 |
12 |
13 |
14 |
15 |

Add New Post

16 |
17 |
18 | 19 |
20 |
21 | 27 |
28 |
29 | 30 |
31 |
32 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | 47 | 54 | -------------------------------------------------------------------------------- /change-password.php: -------------------------------------------------------------------------------- 1 | query($sql); 12 | if ($checkEmail->num_rows > 0) { 13 | $row = $checkEmail->fetch_object(); 14 | if (password_verify($oldPassword, $row->password)) { 15 | if ($newPassword === $confirmPassword) { 16 | $newPassword = password_hash($newPassword, PASSWORD_DEFAULT); 17 | $updatePassword = $conn->query("UPDATE users SET password='$newPassword' WHERE email='$email'"); 18 | if ($updatePassword) { 19 | echo ""; 20 | echo ""; 21 | } else { 22 | echo ""; 23 | } 24 | } else { 25 | echo ""; 26 | } 27 | } else { 28 | echo ""; 29 | } 30 | } 31 | } 32 | ?> 33 |
34 |
35 |
36 |

Change Password

37 |
38 |
39 |
40 |
41 | 42 | 43 |
44 |
45 | 46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 | 54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | -------------------------------------------------------------------------------- /profile-picture.php: -------------------------------------------------------------------------------- 1 | img) ? $userInfo->img : "demoProfile.png"; 5 | } catch (Exception $e) { 6 | echo $e->getMessage(); 7 | } 8 | 9 | if (isset($_POST['upProImg'])) { 10 | $img = $_FILES['img']; 11 | $imgName = $img['name']; 12 | $imgTmp = $img['tmp_name']; 13 | $imgSize = $img['size']; 14 | $imgError = $img['error']; 15 | $imgExt = explode(".", $imgName); 16 | $imgActualExt = strtolower(end($imgExt)); 17 | $allowed = ["jpg", "jpeg", "png"]; 18 | if (in_array($imgActualExt, $allowed)) { 19 | if ($imgError === 0) { 20 | if ($imgSize < 5000000) { 21 | $imgNewName = uniqid("", true) . "." . $imgActualExt; 22 | $imgDestination = "./images/profilepicture/$imgNewName"; 23 | if (!empty($userInfo->img)) { 24 | unlink("./images/profilepicture/$userInfo->img"); 25 | } 26 | move_uploaded_file($imgTmp, $imgDestination); 27 | $updateImg = $conn->query("UPDATE users SET img='$imgNewName' WHERE email='$email'"); 28 | 29 | if ($updateImg) { 30 | echo ""; 31 | udata(); 32 | echo ""; 33 | } else { 34 | echo ""; 35 | } 36 | } else { 37 | echo ""; 38 | } 39 | } else { 40 | echo ""; 41 | } 42 | } else { 43 | echo ""; 44 | } 45 | } 46 | 47 | ?> 48 |
49 |
50 |
51 |

Profile Picture

52 |
53 |
54 |
55 | 56 |
57 | 58 | 59 |
60 |
61 | 62 |
63 |
64 |
65 |
66 | " alt="" class="img-fluid"> 67 |
68 |
69 |
70 |
71 | -------------------------------------------------------------------------------- /update-profile.php: -------------------------------------------------------------------------------- 1 | query("UPDATE users SET name='$name', dob='$dob', gender='$gender' WHERE email='$email'"); 14 | if ($update) { 15 | echo ";setTimeout(()=> location.href='update-profile', 2000)"; 16 | } else { 17 | echo ""; 18 | } 19 | } 20 | 21 | ?> 22 |
23 |
24 |
25 |

Update Profile

26 |
27 |
28 |
29 |
30 | 31 | 32 |
33 |
34 | 35 | 36 |
37 |
38 | 39 | 40 |
41 | 42 |
43 | 44 |
45 | gender) && $userInfo->gender == "Male" ? "checked" : null ?>> 46 | 47 |
48 |
49 | gender) && $userInfo->gender == "Female" ? "checked" : null ?>> 50 | 51 |
52 |
53 |
54 | 55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | -------------------------------------------------------------------------------- /navbar.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /classes/signup.php: -------------------------------------------------------------------------------- 1 | unameErrMsg = "Please enter your name"; 23 | return false; 24 | } elseif (!preg_match("/^[A-Za-z. ]*$/", $uname)) { 25 | $this->unameErrMsg = "Please enter a valid name"; 26 | return false; 27 | } else { 28 | $this->unameErrMsg = ""; 29 | return true; 30 | } 31 | } 32 | 33 | private function validateUemail($uemail): bool 34 | { 35 | if (empty($uemail)) { 36 | $this->uemailErrMsg = "Please enter your email"; 37 | return false; 38 | } elseif (!filter_var($uemail, FILTER_VALIDATE_EMAIL)) { 39 | $this->uemailErrMsg = "Please enter a valid email"; 40 | return false; 41 | } else { 42 | // check if email already exists 43 | $sql = "SELECT email FROM users WHERE email =?"; 44 | $stmt = $this->conn->prepare($sql); 45 | $stmt->bind_param("s", $uemail); 46 | $stmt->execute(); 47 | $result = $stmt->get_result(); 48 | if ($result->num_rows > 0) { 49 | $this->uemailErrMsg = "Email already exists"; 50 | return false; 51 | } else { 52 | $this->uemailErrMsg = ""; 53 | return true; 54 | } 55 | } 56 | } 57 | 58 | public function validateGender($gender): bool 59 | { 60 | if (empty($gender)) { 61 | $this->genderErrMsg = "Please select your gender"; 62 | return false; 63 | } else { 64 | $this->genderErrMsg = ""; 65 | return true; 66 | } 67 | } 68 | 69 | public function validateDate($dob): bool 70 | { 71 | if (empty($dob)) { 72 | $this->dobErrMsg = "Please enter your date of birth"; 73 | return false; 74 | } else { 75 | $this->dobErrMsg = ""; 76 | return true; 77 | } 78 | } 79 | 80 | public function validatePassword($password): bool 81 | { 82 | if (empty($password)) { 83 | $this->passwordErrMsg = "Please enter your password"; 84 | return false; 85 | } elseif (!preg_match("/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&#]{8,}$/", $password)) { 86 | $this->passwordErrMsg = "Please provide a strong password"; 87 | return false; 88 | } else { 89 | $this->passwordErrMsg = ""; 90 | return true; 91 | } 92 | } 93 | 94 | public function signup($uname, $uemail, $gender, $password, $dob): void 95 | { 96 | $this->uname = $this->conn->real_escape_string($uname); 97 | $this->uemail = $this->conn->real_escape_string($uemail); 98 | $this->gender = $this->conn->real_escape_string($gender); 99 | $this->password = $this->conn->real_escape_string($password); 100 | $this->dob = $this->conn->real_escape_string($dob); 101 | if ($this->validateUname($uname) && $this->validateUemail($uemail) && $this->validateGender($gender) && $this->validateDate($dob) && $this->validatePassword($password)) { 102 | $this->password = password_hash($password, PASSWORD_DEFAULT); 103 | $sql = "INSERT INTO users (name, email, gender, password, dob) VALUES ('$this->uname', '$this->uemail', '$this->gender', '$this->password', '$this->dob')"; 104 | $result = mysqli_query($this->conn, $sql); 105 | if ($result) { 106 | // toastr success position bottom 107 | echo ""; 108 | } else { 109 | echo "Error: " . $sql . "
" . mysqli_error($this->conn); 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /edit-post.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM posts WHERE id='$id'"); 9 | $post = $getPost->num_rows > 0 ? $getPost->fetch_object() : header("location: ./all-post.php"); 10 | 11 | $allCatQuery = $conn->query("SELECT * FROM categories"); 12 | $allCats = $allCatQuery->fetch_all(MYSQLI_ASSOC); 13 | 14 | if (isset($_POST['update-post'])) { 15 | $title = $conn->real_escape_string($_POST['title']); 16 | $category = $conn->real_escape_string($_POST['category']); 17 | $details = $conn->real_escape_string($_POST['details']); 18 | $img = $_FILES['img']['name']; 19 | $imgTmp = $_FILES['img']['tmp_name']; 20 | $imgExt = pathinfo($img, PATHINFO_EXTENSION); 21 | $allowedExt = ['jpg', 'jpeg', 'png', 'gif']; 22 | 23 | // Check if image exists in the request 24 | if (!empty($img)) { 25 | // Delete previous image 26 | $prevImg = $post->img; 27 | if (!empty($prevImg)) { 28 | unlink("./images/blog/$prevImg"); 29 | } 30 | 31 | // Upload new image 32 | if (in_array($imgExt, $allowedExt)) { 33 | $newImg = uniqid() . ".$imgExt"; 34 | move_uploaded_file($imgTmp, "./images/blog/$newImg"); 35 | } else { 36 | echo ""; 37 | exit; 38 | } 39 | } 40 | 41 | // Update the database 42 | $updatePost = $conn->query("UPDATE posts SET title='$title', category_id='$category', details='$details'" . (!empty($img) ? ", img='$newImg'" : "") . " WHERE id='$id'"); 43 | if ($updatePost) { 44 | echo ""; 45 | echo ""; 46 | } else { 47 | echo ""; 48 | } 49 | } 50 | 51 | ?> 52 |
53 |
54 |
55 | 56 |
57 |
58 |

Edit Post

59 |
60 |
61 | 62 |
63 |
64 | 70 |
71 |
72 | 75 |
76 |
77 | 82 |
83 |
84 | 85 |
86 |
87 |
88 |
89 |
90 | 91 | -------------------------------------------------------------------------------- /signup.php: -------------------------------------------------------------------------------- 1 | sanitize($_POST['uname']); 14 | $uemail = $signup->sanitize($_POST['uemail']); 15 | $gender = isset($_POST['gender']) ? $signup->sanitize($_POST['gender']) : ""; 16 | $dob = $signup->sanitize($_POST['dob']); 17 | $password = $signup->sanitize($_POST['password']); 18 | $signup->signup($uname, $uemail, $gender, $password, $dob); 19 | } 20 | 21 | ?> 22 |
23 |
24 |
25 |

Sign Up

26 |
27 |
28 | 30 |
31 | unameErrMsg ?? null ?> 32 |
33 |
34 |
35 | 36 |
37 | uemailErrMsg ?? null ?> 38 |
39 |
40 |
rounded py-2"> 41 |
42 | 43 |
44 |
45 | > 46 | 47 |
48 |
49 | > 50 | 51 |
52 |
53 |
54 | genderErrMsg ?? null ?> 55 |
56 |
57 |
58 | 59 |
60 | dobErrMsg ?? null ?> 61 |
62 |
63 |
64 | 65 |
66 | passwordErrMsg ?? null ?> 67 |
68 |
69 |
70 | 71 | 72 |
73 |
74 | 75 |
76 |
77 |
78 |
79 |
80 | 81 | 84 | 85 | -------------------------------------------------------------------------------- /all-post.php: -------------------------------------------------------------------------------- 1 | real_escape_string($_POST['title']); 5 | $category = $conn->real_escape_string($_POST['category']); 6 | $details = $conn->real_escape_string($_POST['details']); 7 | $image = $_FILES['img']; 8 | $imageName = $image['name']; 9 | $imageTmp = $image['tmp_name']; 10 | $imageSize = $image['size']; 11 | $imageError = $image['error']; 12 | $imageType = $image['type']; 13 | $imageExt = explode('.', $imageName); 14 | $imageActualExt = strtolower(end($imageExt)); 15 | $allowed = ['jpg', 'jpeg', 'png', 'gif']; 16 | if (in_array($imageActualExt, $allowed)) { 17 | if ($imageError === 0) { 18 | if ($imageSize < 1000000) { 19 | $newImageName = uniqid('', true) . '.' . $imageActualExt; 20 | $imageDestination = './images/blog/' . $newImageName; 21 | $move = move_uploaded_file($imageTmp, $imageDestination); 22 | if ($move) { 23 | $conn->query("INSERT INTO `posts` (`title`,`category_id`,`details`,`img`) VALUES ('$title','$category','$details','$newImageName')"); 24 | echo ""; 25 | } 26 | } else { 27 | echo ""; 28 | } 29 | } else { 30 | echo ""; 31 | } 32 | } else { 33 | echo ""; 34 | } 35 | } 36 | $posts = $conn->query("SELECT * FROM posts"); 37 | $allPosts = $posts->fetch_all(MYSQLI_ASSOC); 38 | ?> 39 | 40 | 41 |
42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 |

All Posts

50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 69 | 77 | 81 | 82 | 83 | 84 |
S.NPost TitleImageCategoryAction
70 | query("SELECT * FROM categories WHERE id='$catId'"); 73 | $category = $cat->fetch_object(); 74 | echo $category->name; 75 | ?> 76 | 78 | Edit 79 | Delete 80 |
85 |
86 |
87 |
88 |
89 |
90 | 99 | -------------------------------------------------------------------------------- /category.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM categories"); 7 | return $allCatData->fetch_all(MYSQLI_ASSOC); 8 | } 9 | 10 | $allCat = getCatData(); 11 | 12 | if (isset($_POST['addCat'])) { 13 | $catname = $_POST['catname']; 14 | $token = $_POST['token']; 15 | $checkToken = $conn->query("SELECT * FROM `token` WHERE `name`='$token'"); 16 | if ($checkToken->num_rows > 0) { 17 | echo ""; 18 | } else { 19 | $conn->query("INSERT INTO `token` (`name`) VALUES ('$token')"); 20 | $conn->query("INSERT INTO categories (`name`) VALUES ('$catname')"); 21 | echo ""; 22 | $allCat = getCatData(); 23 | } 24 | } 25 | if (isset($_POST['editCat'])) { 26 | $catname = $_POST['catname']; 27 | $catId = $_GET['eid']; 28 | $conn->query("UPDATE categories SET `name`='$catname' WHERE id='$catId'"); 29 | echo ""; 30 | } 31 | if (isset($_POST['deleteCat'])) { 32 | $catId = $_GET['did']; 33 | $conn->query("DELETE FROM categories WHERE id='$catId'"); 34 | echo ""; 35 | } 36 | ?> 37 |
38 |
39 |
40 | 41 |
42 |
43 | 44 |
45 |
46 |

Categories

47 |
48 | 49 |
50 | 51 |
52 |
53 | 54 |
55 |
56 |
57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 | 78 | 79 | 82 | 83 |
S.NCategory NameAction
75 | Edit 76 | Delete 77 |
84 |
85 |
86 | 87 | 88 |
89 |
90 |

Edit Category

91 | query("SELECT * FROM categories WHERE id='$catId'"); 94 | $catData = $getCatData->fetch_object(); 95 | ?> 96 |
97 |
98 | 99 |
100 |
101 | 102 |
103 |
104 |
105 |
106 | 107 | 109 |
110 |
111 | Do you want to delete this category? 112 |
113 | 114 |
115 | No 116 |
117 |
118 | 119 |
120 |
121 |
122 | -------------------------------------------------------------------------------- /cmbd234.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 5.2.1 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: Nov 17, 2024 at 11:40 AM 7 | -- Server version: 10.4.32-MariaDB 8 | -- PHP Version: 8.2.12 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | START TRANSACTION; 12 | SET time_zone = "+00:00"; 13 | 14 | 15 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 16 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 17 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 18 | /*!40101 SET NAMES utf8mb4 */; 19 | 20 | -- 21 | -- Database: `cmbd234` 22 | -- 23 | 24 | -- -------------------------------------------------------- 25 | 26 | -- 27 | -- Table structure for table `categories` 28 | -- 29 | 30 | CREATE TABLE `categories` ( 31 | `id` int(11) NOT NULL, 32 | `name` varchar(255) NOT NULL 33 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; 34 | 35 | -- 36 | -- Dumping data for table `categories` 37 | -- 38 | 39 | INSERT INTO `categories` (`id`, `name`) VALUES 40 | (1, 'Sports'), 41 | (2, 'Politics'); 42 | 43 | -- -------------------------------------------------------- 44 | 45 | -- 46 | -- Table structure for table `posts` 47 | -- 48 | 49 | CREATE TABLE `posts` ( 50 | `id` int(11) NOT NULL, 51 | `title` varchar(255) NOT NULL, 52 | `category_id` int(11) NOT NULL, 53 | `details` longtext NOT NULL, 54 | `img` varchar(150) NOT NULL, 55 | `created_at` timestamp NOT NULL DEFAULT current_timestamp() 56 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; 57 | 58 | -- 59 | -- Dumping data for table `posts` 60 | -- 61 | 62 | INSERT INTO `posts` (`id`, `title`, `category_id`, `details`, `img`, `created_at`) VALUES 63 | (1, 'Shakib-AL-Hasan is at Omrah', 1, '

\"Shakib will reach home at 10 am on 6 February. He will then play their next match on 7 February against Comilla Victorians,\" A Fortune Barishal media release read.

Barishal are currently second in the BPL table with 14 points from 10 matches. They have two more matches before the playoffs - the first against Comilla on 7 February and on 10 February against Khulna Tigers.

 

Shakib has been in tremendous form leading his side from the front. He is currently the second-highest scorer of the ongoing BPL campaign with 347 runs to his name at an average of 49.57 and a strike rate of 183.59. He has bagged three half-centuries so far. The southpaw also picked up seven wickets with the ball.

', '6739c6c885cbe5.59970848.jpg', '2024-11-17 10:34:48'), 64 | (2, 'Why are we so opposed to seeing Hero Alom in politics?', 2, '

In Bogura-4, he lost by 834 votes to the candidate from Jatiya Samajtantrik Dal (JSD), an ally of the ruling Awami League. (Awami League supported the JSD candidate and did not nominate their candidate in Bogura-4).

On the election night, Hero Alom held a press conference where he rejected the election results and alleged result manipulation. \"Educated people would be forced to call illiterates like me \'Sir.\' That\'s why they don\'t want to accept me. They could not accept my victory… That is why the election officials changed the results,\" he claimed.

', '6739c71b3ec639.41157608.jpg', '2024-11-17 10:36:11'); 65 | 66 | -- -------------------------------------------------------- 67 | 68 | -- 69 | -- Table structure for table `token` 70 | -- 71 | 72 | CREATE TABLE `token` ( 73 | `id` int(11) NOT NULL, 74 | `name` varchar(255) NOT NULL 75 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; 76 | 77 | -- 78 | -- Dumping data for table `token` 79 | -- 80 | 81 | INSERT INTO `token` (`id`, `name`) VALUES 82 | (1, '6739c61668256'), 83 | (2, '6739c619352c6'); 84 | 85 | -- -------------------------------------------------------- 86 | 87 | -- 88 | -- Table structure for table `users` 89 | -- 90 | 91 | CREATE TABLE `users` ( 92 | `id` int(11) NOT NULL, 93 | `name` varchar(255) NOT NULL, 94 | `email` varchar(255) NOT NULL, 95 | `gender` varchar(10) NOT NULL, 96 | `password` varchar(255) NOT NULL, 97 | `dob` varchar(150) NOT NULL, 98 | `img` varchar(255) DEFAULT NULL, 99 | `role` varchar(20) NOT NULL DEFAULT 'user', 100 | `created_at` timestamp NOT NULL DEFAULT current_timestamp() 101 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; 102 | 103 | -- 104 | -- Dumping data for table `users` 105 | -- 106 | 107 | INSERT INTO `users` (`id`, `name`, `email`, `gender`, `password`, `dob`, `img`, `role`, `created_at`) VALUES 108 | (1, 'Mujahidul Islam', 'mujahid@gmail.com', 'Male', '$2y$10$A2Xx1FT/j4ND/9wy6jv7FOgcG6MJyiTPX2cc3hkdAWP4C46T4yPli', '2004-10-18', '6739c4a889c544.00987571.jpg', 'admin', '2024-11-17 10:23:50'); 109 | 110 | -- 111 | -- Indexes for dumped tables 112 | -- 113 | 114 | -- 115 | -- Indexes for table `categories` 116 | -- 117 | ALTER TABLE `categories` 118 | ADD PRIMARY KEY (`id`); 119 | 120 | -- 121 | -- Indexes for table `posts` 122 | -- 123 | ALTER TABLE `posts` 124 | ADD PRIMARY KEY (`id`), 125 | ADD KEY `category_id` (`category_id`); 126 | 127 | -- 128 | -- Indexes for table `token` 129 | -- 130 | ALTER TABLE `token` 131 | ADD PRIMARY KEY (`id`); 132 | 133 | -- 134 | -- Indexes for table `users` 135 | -- 136 | ALTER TABLE `users` 137 | ADD PRIMARY KEY (`id`); 138 | 139 | -- 140 | -- AUTO_INCREMENT for dumped tables 141 | -- 142 | 143 | -- 144 | -- AUTO_INCREMENT for table `categories` 145 | -- 146 | ALTER TABLE `categories` 147 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 148 | 149 | -- 150 | -- AUTO_INCREMENT for table `posts` 151 | -- 152 | ALTER TABLE `posts` 153 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 154 | 155 | -- 156 | -- AUTO_INCREMENT for table `token` 157 | -- 158 | ALTER TABLE `token` 159 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 160 | 161 | -- 162 | -- AUTO_INCREMENT for table `users` 163 | -- 164 | ALTER TABLE `users` 165 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; 166 | 167 | -- 168 | -- Constraints for dumped tables 169 | -- 170 | 171 | -- 172 | -- Constraints for table `posts` 173 | -- 174 | ALTER TABLE `posts` 175 | ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`); 176 | COMMIT; 177 | 178 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 179 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 180 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 181 | --------------------------------------------------------------------------------