I'm busy ***learning*** PHP and have been following a tutorial to create a basic site where you can register and have a user account/change your password/update info etc.

I'm on the part where you change your password (I'm at about 6:10 in this [Video](https://www.youtube.com/watch?v=nhAIU-p8Tk4)) and I've become stuck. As far as I'm concerned I have done everything he has done in the tutorial but when I submit my form I get the following errors below. Please go easy on me as I'm sure I have left out a "," or spelled something wrong but for the life of me I can't find it. (Note: When I submit the form I do type in my current password but I get the validation error saying I haven't.) 

*(Update: Marking this post as duplicate and pointing me to another post is not very helpful. As I tried to stress above I am just learning PHP and therefore can't tease a solution out of the post and somehow relate it to my problem.)*

> 
> **Notice:** Undefined index: password\_current in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_current in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_new in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_new in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_new\_again in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_new\_again in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> **Notice:** Undefined index: password\_new\_again in C:\wamp\www\Movrate\classes\Validate.php on line 15
> 
> 
> 

password\_current is required

password\_new is required

password\_new\_again is required

Here is my code for the update password page:

```
    <?php
require_once 'core/init.php';

$user = new User();

if(!$user->isLoggedIn()) {
    Redirect::to('index.php');
}

if(Input::exists()) {
    if(Token::check(Input::get('token'))) {

        $validate = new Validate();
        $validation = $validate->check($_POST, array(
            'password_current' => array(
                'required' => true,
                'min' => 6
            ),
            'password_new' => array(
                'required' => true,
                'min' => 6
            ),
            'password_new_again' => array(
                'required' => true,
                'min' => 6,
                'matches' => 'password_new'
            )
        ));

        if($validation->passed()) {
            // change of password
        } else {
            foreach($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }

    }
}
?>

<form action="" method="post">
    <div class="field">
        <lable for="password_current">Current password</label>
        <input type="password" name="passsword_current" id="password_current">
    </div>

    <div class="field">
        <lable for="password_new">New password</label>
        <input type="password" name="passsword_new" id="password_new">
    </div>

    <div class="field">
        <lable for="password_new_again">New password again</label>
        <input type="password" name="passsword_new_again" id="password_new_again">
    </div>

    <input type="submit" value="Change">
    <input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</form>

```

Here is the code for my validate class:

```
<?php
class Validate {
    private $_passed= false,
            $_errors = array(),
            $_db = null;

    public function __construct() {
        $this->_db = DB::getInstance();
    }

    public function check($source, $items = array()) {
        foreach ($items as $item => $rules) {
            foreach ($rules as $rule => $rule_value) {

                $value = trim($source[$item]);
                $item = escape($item);

                if($rule === 'required' && empty($value)) {
                    $this->addError("{$item} is required");
                } else if(!empty($value)) {
                    switch($rule) {
                        case 'min':
                            if(strlen($value) < $rule_value) {
                                $this->addError("{$item} must be a minimum of {$rule_value} characters.");
                            }
                        break;
                        case 'max':
                            if(strlen($value) > $rule_value) {
                                $this->addError("{$item} must be a maximum of {$rule_value} characters.");
                            }
                        break;
                        case 'matches':
                            if($value != $source[$rule_value]) {
                                $this->addError("{$rule_value} must match {$item}");
                            }
                        break;
                        case 'unique':
                            $check = $this->_db->get($rule_value, array($item, '=', $value)); 
                            if($check->count()) {
                                $this->addError("{$item} already exists.");
                            }
                        break;
                    }
                }

            }
        }

        if(empty($this->_errors)){
            $this->_passed = true;
        }

        return $this;
    }

    private function addError($error) {
        $this->_errors[] = $error;
    }

    public function errors() {
        return $this->_errors;
        }

    public function passed() {
        return $this->_passed;
    }

}

```