PHP $_POST接受不到資料,但$_GET可以接受資料

來源:互聯網
上載者:User
關鍵字 php
新手一枚,代碼如下,把post 改成 get 就沒問題,但如果是post 就會提示
Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3

add.html

        Title

add.php

   

回複內容:

新手一枚,代碼如下,把post 改成 get 就沒問題,但如果是post 就會提示
Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3

add.html

        Title

add.php

   

我也是類似的問題,只有一種可能,就是你得phpstrom配置的連接埠與phpinfo()連接埠不符。先看一下phpinfo()?>的連接埠在哪裡比如localhost,那麼就配置phpstrom-》Tools-》Dployment-》Configuration-》
建立比如Name=localhost,然後設定Web sever root url為http://localhost,連接埠與phpinfo()連接埠一致即可

php.ini 中配置 enable_post_data_reading 為 On, 這樣才會自動將 POST 資料填入 $_POST 數組中。

; Whether PHP will read the POST data.; This option is enabled by default.; Most likely, you won't want to disable this option globally. It causes $_POST; and $_FILES to always be empty; the only way you will be able to read the; POST data will be through the php://input stream wrapper. This can be useful; to proxy requests or to process the POST data in a memory efficient fashion.; http://php.net/enable-post-data-reading; enable_post_data_reading = Off

判斷是否輸入a和b的值,應該使用:

isset($_POST['a']) && isset($_POST['b']

你的寫法在a或b輸入0值時,不會走相加分支。

列印 $_REQUEST數組,

如果查驗是否有資料POST過來,如果沒有確定的條件下,推薦在業務處理前先進行列印資料。
上面可以直接
var_dump($_POST);
看下是否有值。

post有好幾種方式,你看你是什麼方式提交的?

php配置問題吧

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.