簡體   English   中英

CakePHP-從Post獲取變量

[英]CakePHP - Get a variable from Post

我有一個看起來像這樣的表格:

<?php
echo $this->form->create('User');
echo $this->form->input('username');
echo $this->form->input('email');
echo $this->form->input('password');
echo $this->form->end('Save');
?>

以及提交文件的控制器:

if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) { 

        }

我正在嘗試從表單獲取輸入作為變量。 就像是..

if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) { 

          $username = $this->form->input('username');

        }

這可能嗎? 從表單獲取輸入並將其存儲為變量以用於其他用途?

謝謝大家!

使用:Cakephp 2.x

這就是您獲取價值的方式

$this->request->data['User']['username']

User名是您在$this->Form->create() username的名稱, username是字段名

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM