Jump to content

Archived

This topic is now archived and is closed to further replies.

Rommeo

How to make an admin panel ?

Recommended Posts

Hi

 

I'm curious about how you build admin panels. I m trying to make an admin panel. I have some pages like "addnews.php editnews.php deletenews.php / addphoto.php editphoto.php deletephoto.php

 

Now i wanna give link to these files.

 

What should i do now ?

should i create an panel.php file

and use an if statement like

if ( $page == 'addnews' ) 
     include['addnews.php']
else if ( $page == 'editnews']
...

then when you want to add page, you should enter www.site.com/panel.php?process = addnews

 

or

 

should i give link to every file from the panel.php file. when you enter www.site.com/addnews.php

at this time i should add a small script to every file for anyone not to reach directly.

 

How do you deal with the files that you dont want anyone to reach directly?

i will be glad if anyone can help.

 

thanks in advance.

 

Share this post


Link to post
Share on other sites

Dont create seperate pages like addnews.php editnews.php delnews.php merge them all it on to one file - news.php then use urls like

 

admin.php?module=news&action=add

admin.php?module=news&action=edit

admin.php?module=news&action=delete

 

to do whatever you want. Here is how you implement it:

 

In admin.php you'd do something like

 

if(isset($_GET['module']) && file_exists('./'.$_GET['module'].'.php')
{
   // include the module eg news.php
   include $_GET['module'] . '.php';
}

 

Now in your modules you'll use this base code

if(isset($_GET['action']))
{
    switch($_GET['action']))
    {
        /* possible actions for module */

        case 'add':
            /* code to add*/
        break;

        case 'edit':
            /* code to edit*/
        break;

        case 'del':
            /* code to delete*/
        break;

        default:
            die('Invalid Command');
        break;
}

Share this post


Link to post
Share on other sites

wildteen88 thank you for the quick reply ..

 

but what makes me think is

action "add" for the "news" and the action "add" for the "photo" is different. In your example you just include the module not the action. How can i deal with it at that time ?

 

Would be so glad if you can show me a tutorial about it.

Trying to figure it out.

 

 

Share this post


Link to post
Share on other sites

No, the action is handled by the module. admin.php just includes the requested module.

 

This first part of the code:

if(isset($_GET['module']) && file_exists('./'.$_GET['module'].'.php')
{
   // include the module eg news.php
   include $_GET['module'] . '.php';
}

Goes in admin.php. This just includes the module, eg news.php, photo.php etc

 

The second part:

if(isset($_GET['action']))
{
    switch($_GET['action']))
    {
        /* possible actions for module */

        case 'add':
            /* code to add*/
        break;

        case 'edit':
            /* code to edit*/
        break;

        case 'del':
            /* code to delete*/
        break;

        default:
            die('Invalid Command');
        break;
}

Goes in your module eg news.php, photo.php

Example setup now attached

 

[attachment deleted by admin]

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.