PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] how to get the value on form input in cakephp

 March 13, 2022     cakephp, php, validation     No comments   

Issue

I have:

echo $this->Form->input('username', array('label' => 'Username: '));

equivalent to in traditional php coding..

how can I get the value inputted in that textbox like when you do $val = $_POST['username']; in traditional php coding.

I need this for login validation. thanks


Solution

You can get it

$val = $this->data['ModelName']['username']; //CakePHP 1.X.X

//or

$this->request->data['ModelName']['username']); //CakePHP 2.X.X

Where "ModelName" is your currently assigned model to form.

Update:

$user = $this->Account->find('first', array(
   'conditions' => array(
      'username' => 'user1'
   )
));


Answered By - Aurimas Ličkus
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing