I'm new to cakePHP.I just tried to create a simple form with a text box and a submit button on view and display the text using post data on the controller.
My View Code :
<?php echo $form->create(null, array('action' => 'index'));?>
<fieldset><legend>Enter Your Name</legend><?php echo $form->input('name'); ?></fieldset>
<?php echo $form->end('Go');?>
My controller code :
<?php
class UsersController extends AppController {
var $name = 'Users';
var $uses = array();
var $helpers = array('Html','Form');
function index() {
if ( !empty($this->data) ) {
echo $this->data['name'];
$this->autoRender = false;
}
}
}
?>
I'm receiving the error ,
Notice (8): Undefined variable: form [APP/View/Users/index.ctp, line 1]
Code Context
include - APP/View/Users/index.ctp, line 1
View::_render() - CORE/Cake/View/View.php, line 598
View::render() - CORE/Cake/View/View.php, line 365
Controller::render() - CORE/Cake/Controller/Controller.php, line 900
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 114
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 89
[main] - APP/webroot/index.php, line 96
What is the problem in this.
Thanks in advance.