0

I'm in the middle of creating an admin panel however I'm wondering if its possible and how to do the following.

The admin panel will allow the user to complete three actions which are add, edit and delete (whilst communicating with the MySQL database). How can these actions only be completed within one file for example index.php?page=add, index.php?page=edit, index.php?page=delete?

So when the user wants to delete something only the delete part of the code is accessed in the file?

Thanks,

Jack

4

2 に答える 2

1

You'd need to be passing more info, for example a user id.

$userid = filter_var($_GET['userId'], FILTER_VALIDATE_INT);   

switch($_GET['page'])
{
    case 'add':
        // build mysql insert here using the userid.
        break;

    case 'edit':
        // build mysql update here using the userid.
        break;

    case 'delete':
        // build mysql delete here using the userid.
        break;

    default:
        echo 'unknown page action';
}
于 2012-05-27T14:29:14.000 に答える
0

$_GET['page']ページ」に関連付けられた URL から PHP で値を取得できます。

$_POST を使用すると、データから「post」経由で送信されます。いくつかの例については、次のチュートリアルを参照してください: $_GET, $_POST and $_REQUEST Variables .

于 2012-05-27T14:31:26.760 に答える