- Saved searches
- Use saved searches to filter your results more quickly
- License
- housamz/php-mysql-admin-panel-generator
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Simple PHP Admin Panel (Free Download)
- TABLE OF CONTENTS
- PHP MYSQL ADMIN PANEL
- PART 1) USER DATABASE
- PART 2) PHP ADMIN LIBRARY
- PART 3) LOGIN PAGE
- ADMIN LOGIN
- Админ-панель сайта
- Авторизация администратора
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
PHP MySQL Admin-panel Generator (MAGE), a PHP tool that helps you create a PHP CRUD system for any MySQL database in seconds.
License
housamz/php-mysql-admin-panel-generator
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
MAGE :: PHP MySQL Admin Panel Generator
Available for Python also: Python Mage
PHP MySQL Admin Panel Generator (MAGE), a PHP tool that helps you create a PHP Admin Panel for any MySQL database in seconds.
Mage is not PHPMyAdmin; it doesn’t contain all your databases. It physically creates an admin panel for a database.
A suggested use-case for the tool would be creating an admin panel for a PHP / MySQL project in seconds, and then you can tweak it before delivery.
You may use this tool for charity or school projects, for commercial use, please contact me.
MAGE is derived from M ySql A dmin panel GE nerator. Mage (meɪdʒ): a magician or learned person.
Disclaimer: Always backup your database.
Note: You need to make sure that you have php-mysql package that connects PHP with MySQL, and that you change the generated directory permissions to be 777.
Step | Thumb | Instructions |
---|---|---|
1 | Start by providing your MySQL Server Info, then click Next Step button. | |
2 | The tool will scan the server for available databases and list them in a dropdown menu, select the database that you want, then check if you need full HTML editor or not, and then click «Generate Admin Panel» button | |
3 | After a few seconds, you’ll get a success message, with a link to the newly created admin panel, and a report of all the operations that were done. | |
4 | Click the link to the admin panel. You have to sign in using «admin» as an email and a password. |
You’ll get a clean bootstrap interface to control the website, check below screenshots:
MAGE handles data using htmlentities as well as addslashes to prevent XSS attacks. This means that any HTML tags, especially those generated by the CKEditor, will be encoded.
If you want to display the original HTML code use html_entity_decode() around that specific field.
If you don’t need HTML tags at all, you can disable CKEditor by unchecking the checkbox before clicking «Generate Admin Panel».
Nothing happens when you provide credentials on home page
You need to install php-mysql package, the following installs the latest version.
sudo apt install php-mysql service apache2 restart
Nothing happens when I click Generate button
Change the generated directory permission to 777
About
PHP MySQL Admin-panel Generator (MAGE), a PHP tool that helps you create a PHP CRUD system for any MySQL database in seconds.
Simple PHP Admin Panel (Free Download)
Welcome to a tutorial on how to create a simple PHP admin panel. Since you are reading this, I will assume that you are interested in “powering up” your existing project and want to build an administrative component to it. So here is a sharing of my own – All done in pure HTML, CSS, Javascript, and PHP. No third-party frameworks. Read on!
TABLE OF CONTENTS
PHP MYSQL ADMIN PANEL
All right, let us now get into the details of how to create a simple admin panel with PHP and MySQL.
PART 1) USER DATABASE
-- (A) USERS TABLE CREATE TABLE `users` ( `user_id` bigint(20) NOT NULL, `user_email` varchar(255) NOT NULL, `user_name` varchar(255) NOT NULL, `user_password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `users` ADD PRIMARY KEY (`user_id`), ADD UNIQUE KEY `user_email` (`user_email`), ADD KEY `user_name` (`user_name`); ALTER TABLE `users` MODIFY `user_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1; -- (B) DEFAULT USER -- EMAIL: JOY@DOE.COM | PASSWORD: 123456 INSERT INTO `users` (`user_id`, `user_email`, `user_name`, `user_password`) VALUES (1, 'joy@doe.com', 'Joy Doe', '$2y$10$vZJy7y4uqQQTRN3zdi2RE.5ZJJzGEEPnzEjFXm4nEOx023XQ2Qe..');
- user_id Primary key and auto-increment.
- user_email User email, unique to prevent duplicates.
- user_name User name.
- user_password The user’s password.
PART 2) PHP ADMIN LIBRARY
pdo = new PDO( "mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset=".DB_CHARSET, DB_USER, DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); > // (B) DESTRUCTOR - CLOSE CONNECTION function __destruct () < if ($this->stmt !== null) < $this->stmt = null; > if ($this->pdo !== null) < $this->pdo = null; > > // (C) HELPER FUNCTION - RUN SQL QUERY function query ($sql, $data=null) : void < $this->stmt = $this->pdo->prepare($sql); $this->stmt->execute($data); > // (D) GET USER BY ID OR EMAIL function get ($id) < $this->query(sprintf("SELECT * FROM `users` WHERE `%s`=?", is_numeric($id) ? "user_id" : "user_email" ), [$id]); return $this->stmt->fetch(); > // (E) SAVE USER function save ($name, $email, $password, $id=null) < // (E1) SQL & DATA $sql = $id==null ? "INSERT INTO `users` (`user_name`, `user_email`, `user_password`) VALUES (. )" : "UPDATE `users` SET `user_name`=?, `user_email`=?, `user_password`=? WHERE `user_id`=?" ; $data = [$name, $email, password_hash($password, PASSWORD_DEFAULT)]; if ($id!=null) < $data[] = $id; >// (E2) RUN SQL $this->query($sql, $data); return true; > // (F) VERIFICATION function verify ($email, $password) < // (F1) GET USER $user = $this->get($email); $pass = is_array($user); // (F2) CHECK PASSWORD if ($pass) < $pass = password_verify($password, $user["user_password"]); >// (F3) REGISTER MEMBER INTO SESSION if ($pass) < foreach ($user as $k=>$v) < $_SESSION["admin"][$k] = $v; >unset($_SESSION["admin"]["user_password"]); > // (F4) RESULT if (!$pass) < $this->error = "Invalid email/password"; > return $pass; > > // (G) DATABASE SETTINGS - CHANGE TO YOUR OWN define("DB_HOST", "localhost"); define("DB_NAME", "test"); define("DB_CHARSET", "utf8mb4"); define("DB_USER", "root"); define("DB_PASSWORD", ""); // (H) START! session_start(); $_ADM = new Admin();
This PHP core and database library is here to help you guys develop a little faster. It may look confusing at first, but keep calm and look closely.
- (A, B, H) When $_ADM = new Admin() is created, the constructor will connect to the database. The destructor closes the connection.
- (C) query() A helper function to execute an SQL query.
- (D to F) The actual admin functions.
- get() Get user by ID or email.
- save() Add or update a user.
- verify() Verify the given email and password. Register the user into $_SESSION[«admin»] .
PART 3) LOGIN PAGE
verify($_POST["email"], $_POST["password"]); > // (C) REDIRECT IF SIGNED IN if (isset($_SESSION["admin"])) < header("Location: 5-protected.php"); exit(); >?> error!="") < echo "?>
ADMIN LOGIN
It will be easier to study this login page from the bottom up.
- (D) A good old HTML login form.
- (A & B) On submission, we use the library to process the login request.
- (C) On successful login, we redirect the user to the “main admin page”; Any users who are already signed in will also be redirected.
Админ-панель сайта
Админ-панель сайта — это часть движка, предназначенная для автоматического добавления контента на сайт. На ней есть поле, куда Вы пишете текст статьи. Админ панель содержит скрипты, которые создают новые страницы сайта либо добавляют статью в БД, в зависимости от структуры сайта. В меню добавляется ссылка на статью. Обычно админ-панель даёт возможность добавлять не только текст, но и другой контент. Создавая движок сайта, Вы сами решаете, делать админ-панель или добавлять статьи самостоятельно.
Админ-панель располагается на отдельной странице, которая имеет примерно такой адрес:
На сайте не делают ссылки на эту страницу, Вы просто должны знать её URL. Вход в админ-панель производится через форму авторизации. От обычной авторизации она отличается тем, что вы входите не как обычный пользователь, а как администратор, и информация об этом должна быть записана в сессию. Доступ к админ-панели должен быть только у администратора.
Авторизация администратора
Авторизацию администратора можно сделать двумя способами. Если администраторов несколько, то в таблицу с пользователями можно добавить поле, в котором указывать, что пользователь является администратором. А можно в скрипте авторизации просто передавать права администратора конкретному пользователю. Мы используем второй вариант. Назовём страницу авторизации avtadministrator.html. Вот её код:
Форма отправляет данные в файл adminavt.php. Это скрипт авторизации. Его код такой: