duangenshi9836 2014-10-17 17:21
浏览 37
已采纳

如果我使用GET和Front Controller,这是否意味着我必须对所有表格使用GET?

I have a front controller class. In that class I have function to parse a url:

public function parseURL()
{
    if(isset($_GET['url']))
    {
        return $url = explode('/',filter_var(rtrim($_GET['url'],'/'),FILTER_SANITIZE_URL));
    }

}

This is based upon a RewriteRule (What I imported into IIS anyway):

Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

Does this mean all of my forms now need to use GET?

<form action="/controller/action" method="GET">

Doesn't everything go through the front controller, even my CRUD?

/controller/action/id, for example.

If it matters I am using IIS. I do not have any hidden inputs for put, delete, etc. I am not currently using AJAX.

  • 写回答

1条回答 默认 最新

  • dongzhang1987 2014-10-17 17:28
    关注

    No, your forms can still use POST. I would advise that you do not use GET when submitting form values as you will pollute your URL with form data.

    You can also access your GET attributes just fine.

    <form action="/controller/action/id" method="POST">
        <input type="text" name="someText" />
        <input type="submit />
    </form>
    

    In PHP, you do your business as usual:

    echo $_POST['someText']; //echos the input from the form control
    echo $_GET['url']; //echos "/controller/action/id"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog