Managing content from admin area using PHP MySQL

This is a very basic solution and more features can be added to this script. This script can be a part of any website or can be integrated to any script. This script can be used to post news, jokes, events and many other similar types of contents.

Here the site admin posts content from inside the admin area. The admin can select a category and then add title, date, short description and full details of the content.

How the content management script works.

Site admin will login and enter into admin area. You can read the login script and learn how the pages are managed inside logged in area. There is a file check.php which checks the status of site-admin and allows the page execution. Admin can manage category by adding, deleting or editing name of any category. The page category.php takes care of this and while editing and category name it opens a child window and allows the admin to update the category name. We have used JavaScript refreshing parent window from child window technique to update the main page ( category.php ) with new category name.

Admin can post the content ( read post.php file ) by entering title, short description, date and full description of the news or event. He can assign the content to a particular category. There is a server side validation to take care of wrong dates, short or long length of posting. It will generate error message saying what is wrong in posting. We have used post back technique to keep the entered content within the form in case of any error message. This will enforce some restrictions like, title must be of some length, short description is to be entered etc.

After posting the content will be available in public area. Admin can view the same details inside admin area and delete them also.

In the main public area the recent top 10 contents ( or news or events ) will be displayed. Please read index.php page. This is done by applying the order by clause in date of post field. Above this all the category names are displayed with the number of content present in that category. Users can click the category name and view that content of that category only.

Installing database tables

Enter your MySQL database login details in config.php file. This file is called by all the files for database connection. Open the mysql-dump.txt file and use it for creating tables and fill it with data.

Three tables are used in this script. The main table name is content. To this table admin posts the content by entering title, date, short description and long description. Here for each record one category ID is assigned. Category names are displayed in a drop down list by taking from content_cat table and only the cat_id is stored along with other data for each record in content table. Each record in content table ( after adding ) gets one unique content identification number while the record is added by using auto increment filed property. This we call cont_id and it is used for handling each record in our table.

The table content_cat is used to store category name. Each category once added by admin generates one unique category identification number and we call that cat_id. We used an auto increment field to generate this incremental unique number for each category. This category name gets linked to the content table by cat_id field. Each category name can be edited or added or delete from the content_cat table but while deleting script will check if any record is assigned to this category in main content table. If records are assigned in content table then category name will not be deleted and a message will be displayed. Same way while adding category name the script will check if that name is already existing or not.

We will be using one more table to validation the admin for entering inside the admin area. We will only store admin user id and password in this table and match with the user entered values in the login page. Please note that the password stored is not encrypted.

Here is the dump of all the three tables.
CREATE TABLE `content` (
  `cont_id` int(3) NOT NULL auto_increment,
  `cat_id` int(3) NOT NULL,
  `dt` date NOT NULL,
  `title` varchar(250) NOT NULL,
  `short_dtl` text,
  `dtl` text NOT NULL,
  UNIQUE KEY `cont_id` (`cont_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

CREATE TABLE `content_admin` (
  `admin_id` varchar(8) NOT NULL,
  `admin_pw` varchar(8) NOT NULL,
  UNIQUE KEY `admin_id` (`admin_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `content_cat` (
  `cat_id` int(11) NOT NULL auto_increment,
  `name` varchar(250) NOT NULL,
  UNIQUE KEY `cat_id` (`cat_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

Login details

The admin login id and password is kept in the first ( only ) record of content_admin table. Use that and login to admin area. Use the admin/login.php file and enter your id and password. First create the categories and then add some contents. By default some records are already there. You can view them in outside the admin area in root of the script. Open index.php file of this. You can delete them from admin area. While viewing the full details of the content , it can be deleted.

Download the full script here
Scripts


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    fareed

    19-01-2009

    nice tutorial
    pankaj choudhary

    14-03-2009

    this is one of the best website for tutorial of php or other web designing languages
    Elandirayan

    26-03-2009

    Thanks to plus2net.com for providing the technical details in very short and clear manner. I hates of for your service. Thank you once again.
    bala

    25-04-2009

    ya thanks for you giving such a wonderful script really this is very useful. thanks plus2net
    maithili

    28-04-2009

    this site is very useful for me
    lily

    12-02-2010

    nice.. helps a lot
    Bonny

    07-04-2011

    This script saved me time when I was creating event manager for my church. Much thanks.

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer