Code of Content Management System in PHP [Project]
The Content Management System for content creators is a simple PHP/MySQLi final year project that handles  the contents of a simple Blog for bloggers. The Content Management System has an Admin Panel where the administrator can manage the contents of the pages.
The “Categories” in this The Content Management System will have a navigation button on the Blog for bloggers’s navigation bar. Also, the admin can create up to 2 levels of categories which means the admin can set the new category as the sub-category.
The Content Management System has 2 default content pages which is the “Home Page” and “About Us Page”. The content can be handled by the admin user. The admin can dynamically create a content page if he/she wants to create under a category.
The Content Management System permits only the admin to create the Blog for bloggers’s contents and the Blog for bloggers only needed the users to signup or login for the purpose of only writing the comments.
Functional Requirements of Content Management System
Admin related Functional Requirements
- The user can view Login
- The user can view Home
- The user can view Category Page
- The user can view Pages List
- The user can view Home Page for content Management
- The user can view About Us page
- The user can view Manage content
- User Management
Users related Functional Requirements
- The user can view Login
- The user can  Signup
- The user can view Home Page
- The user can insert, delete, update and view Category’s List of Contents Page
- The user can insert, delete, update and view Content Page
- The user can insert, delete, update and view Comment Section
- The user can insert, delete, update and view Recent Post Section
- The user can insert, delete, update, view and Search Content
- The user can insert, delete, update and view manage Account
user_list.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
<?php include'db_connect.php' ?> <div class="col-lg-12"> <div class="card card-outline card-success"> <div class="card-header"> <div class="card-tools"> <a class="btn btn-block btn-sm btn-default btn-flat border-primary" href="./index.php?page=new_user"><i class="fa fa-plus"></i> Add New User</a> </div> </div> <div class="card-body"> <table class="table tabe-hover table-bordered" id="list"> <thead> <tr> <th class="text-center">#</th> <th>Name</th> <th>Email</th> <th>Action</th> </tr> </thead> <tbody> <?php $i = 1; $qry = $conn->query("SELECT *,concat(firstname,' ',lastname) as name FROM users order by concat(firstname,' ',lastname) asc"); while($row= $qry->fetch_assoc()): ?> <tr> <th class="text-center"><?php echo $i++ ?></th> <td><b><?php echo ucwords($row['name']) ?></b></td> <td><b><?php echo $row['email'] ?></b></td> <td class="text-center"> <button type="button" class="btn btn-default btn-sm btn-flat border-info wave-effect text-info dropdown-toggle" data-toggle="dropdown" aria-expanded="true"> Action </button> <div class="dropdown-menu" style=""> <a class="dropdown-item view_user" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>">View</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="./index.php?page=edit_user&id=<?php echo $row['id'] ?>">Edit</a> <div class="dropdown-divider"></div> <a class="dropdown-item delete_user" href="javascript:void(0)" data-id="<?php echo $row['id'] ?>">Delete</a> </div> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> </div> </div> <script> $(document).ready(function(){ $('#list').dataTable() $('.view_user').click(function(){ uni_modal("<i class='fa fa-id-card'></i> User Details","view_user.php?id="+$(this).attr('data-id')) }) $('.delete_user').click(function(){ _conf("Are you sure to delete this user?","delete_user",[$(this).attr('data-id')]) }) }) function delete_user($id){ start_load() $.ajax({ url:'ajax.php?action=delete_user', method:'POST', data:{id:$id}, success:function(resp){ if(resp==1){ alert_toast("Data successfully deleted",'success') setTimeout(function(){ location.reload() },1500) } } }) } </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<?php include('./db_connect.php'); session_start(); if(isset($_GET['id'])){ $user = $conn->query("SELECT * FROM users where id =".$_GET['id']); foreach($user->fetch_array() as $k =>$v){ $meta[$k] = $v; } } ?> <div class="container-fluid"> <div id="msg"></div> <form action="" id="manage-user"> <input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>"> <div class="form-group"> <label for="name">First Name</label> <input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required> </div> <div class="form-group"> <label for="name">Last Name</label> <input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required> </div> <div class="form-group"> <label for="email">Email</label> <input type="text" name="email" id="email" class="form-control" value="<?php echo isset($meta['email']) ? $meta['email']: '' ?>" required autocomplete="off"> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" name="password" id="password" class="form-control" value="" autocomplete="off"> <small><i>Leave this blank if you dont want to change the password.</i></small> </div> <div class="form-group"> <label for="" class="control-label">Avatar</label> <div class="custom-file"> <input type="file" class="custom-file-input rounded-circle" id="customFile" name="img" onchange="displayImg(this,$(this))"> <label class="custom-file-label" for="customFile">Choose file</label> </div> </div> <div class="form-group d-flex justify-content-center"> <img src="<?php echo isset($meta['avatar']) ? 'assets/uploads/'.$meta['avatar'] :'' ?>" alt="" id="cimg" class="img-fluid img-thumbnail"> </div> </form> </div> <style> img#cimg{ height: 15vh; width: 15vh; object-fit: cover; border-radius: 100% 100%; } </style> <script> function displayImg(input,_this) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#cimg').attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } $('#manage-user').submit(function(e){ e.preventDefault(); start_load() $.ajax({ url:'ajax.php?action=update_user2', data: new FormData($(this)[0]), cache: false, contentType: false, processData: false, method: 'POST', type: 'POST', success:function(resp){ if(resp ==1){ alert_toast("Data successfully saved",'success') setTimeout(function(){ location.reload() },1500) }else{ $('#msg').html('<div class="alert alert-danger">Username already exist</div>') end_load() } } }) }) </script> |