0

codeigniter を使用すると、次のようにバックエンドで変数を渡すのに問題があります

http://localhost:4949/admin/delete_post/6/?action=delete

生産The URI you submitted has disallowed characters.

この問題は config.php から修正できることはわかって$config['permitted_uri_chars']いますが、バックエンドのフィルタリングから除外し、この種の構造を許可してフロントエンドをそのままにしておくにはどうすればよいでしょうか。

4

2 に答える 2

0

アンパサンド (&) を使用してこのように使用します

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_+&-';

それはあなたの問題を解決するかもしれません。

詳しい説明はこちら

于 2013-03-26T01:24:47.907 に答える
0

この種のフォーマットは、Codeigniter では必要ありません。クエリ文字列を有効にすることはできますが、私の意見では、クエリ文字列を使用することは、物事を処理するコードイグナイターの方法に反します。uri を介してビューから変数を渡すことができるためです。

http://yourdomain_baseurl/controller/controller_function/var1/var2/var3

次のことをお勧めします。

次のような URL で変数を送信します。

http://yourdomain_baseurl/admin/post_action/id/action

「管理者」コントローラーで、次のようなものを作成できます。

function post_action($id, $action){

    switch ($action) {
        case "delete":
            //do something here with your post with id $id
            break;
        case "update":
            //do something here with your post with id $id
            break;
        case "create":
            //do something here with your post with id $id
            break;
    }

}

または、Post アクションごとに別の関数を作成したい場合:

http://yourdomain_baseurl/admin/post_delete/id
http://yourdomain_baseurl/admin/post_edit/id

管理コントローラーで次の関数を使用する

function post_delete($id){
    //Delete Archive the post with $id here!
}

function post_edit($id){
    //edit the post with $id here!
}

ほとんどのユーザー入力はフォームから行われるため、$_POST データを使用してユーザー入力を取得できます。あなたを助ける便利なクラスがあります:

 $this->input->post('some_data');

codeigniter に付属のドキュメントを読んで、以下を読むことをお勧めします。

URL の http://ellislab.com/codeigniter/user-guide/general/urls.html

URL http://ellislab.com/codeigniter/user-guide/general/routing.html

于 2013-03-28T09:07:18.730 に答える