Hello guys ! I am new in PHP And MYSQL..And i want to create an Admin panel with edit , delete, add form..Please help me and yes! along with its data base..(mysql code.)..
Youll need to create the files to perform those functions and make sure the pages are only accessible by an admin.
Creating an admin panel is no different to creating a regular site, except that you need to take more care while coding/using it. Lets say you have a site with 200 products. A basic admin panel should have
- A login page, login.php
- A browse page where all the products are listed, browse.php
- Ability to add new listings, addlisting.php
- Ability to modify an existing listing editlisting.php
On the top of every page, you need to check if the user is logged in as the administrator and redirect him/her to the log in page if they're not. You can do this using PHP sessions. Check out this simple tutorial on how to do that.
When the user logs in, he should be redirected to the browse page where he can browse through the existing products. Assuming you have basic knowledge of PHP and MYSQL, you can achieve this using simple SELECT queries. However, since you have around 200 products, it is not a good idea to list them all on the same page. You should divide them into a number of pages using the LIMIT MYSQL clause. A simple article on pagination. You need to add links to the edit beside every listing and a link to add a new listing on the top of this page.
Creating the new listing page is perhaps the easiest part. Just create a form with all the required inputs. When a form is submitted, you should check that the details submitted are valid before you insert the new listing into the database. Just google "php form validation", there are a lot of related articles and code snippets. If the details are valid, insert the data into the database using the [MySQL INSERT statement](MySQL INSERT statement). If there are some errors in the submissions, display the errors. Don't forget to automatically fill the valid inputs in case of an error, it makes the admin's job a million times easier.
Editing a listing is similar to adding one with a few differences. Firstly, you need to automatically fill the form details with the existing ones in the database when the user first loads the page. Just draw the listing details using a SELECT statement and fill the inputs(use the isset function to fill the details only if the form is not submitted yet). When the user edits the listing details and submits the form, you need to check that the new details are valid just like you did in the add listing page. If they are, update the details in the database using the UPDATE statement.
Important! You should make use of the WHERE clause or else all the product listings will be updated
Now, the reason I said that you need to be careful is that you can mess up your database or let intruders in. If your authentication system is poorly written, somebody might log in to the admin panel without your knowing and edit/delete all the listings. If your SQL statements are poorly written(not using a WHERE clause for example), your entire database might be damaged or deleted. I recommend working on a database copy rather than the original until you're sure everything is safe to use.
P.S I just completed coding my site and creating the admin panel is perhaps the hardest part of it.
If you are new in php, it is good to go by example. Face trouble/errors and solve it/fix it.
If you go to hotscripts.com or similar site, you will get lots of free scripts, which you may take as examples.
If you will understand them, then you will work on your own.
If you are going to write from beginning ,it may take time to write.
Try to learn any php framework for future.Better learn cakephp