Cake PHP:使用Form helper时出现未定义的错误

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.

$form->method is from old versions of CakePHP. In new versions the form helpers are $this->Form->method. So, just replace those instances in your code:

<?php echo $this->Form->create(null, array('action' => 'index'));?>
<fieldset><legend>Enter Your Name</legend><?php echo $this->Form->input('name'); ?></fieldset>
<?php echo $this->Form->end('Go');?> 

Like this

<div class="login"> 
<h2>Login</h2>     
    <?php 

    echo $this->Form->create('User', array('action' => 'login'));?> 
        <?php echo $this->Form->input('username');?> 
        <?php echo $this->Form->input('password');?> 
        <?php echo $this->Form->submit('Login');?> 
    <?php echo $this->Form->end(); ?> 
</div>