I am putting together a user register/login system for a site I'm making, and in the tutorial I am following the salt is supposed to be 32 characters long. This works when I run the script and echo out the salt onto the page as a test, but when I remove the echo command, the code either updates the mySQL DB with a blank salt, or only 1 - 2 characters at the most.
I am really new to PHP (and coding in general) so my lack of knowledge here means I am probably missing something obvious. I have followed the tutorial over and over again, still producing the same results.
Does anyone know why this could be?
Here is the code:
Hash.php
<?php
class Hash {
    public static function make($string, $salt) {
        return hash('sha256', $string . $salt);
    }
    public static function salt($length) {
        return mcrypt_create_iv($length);
    }
    public static function unique() {
        return self::make(uniqid());
    }
}
?>
register.php:
<?php 
require_once 'core/init.php';
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array(
                'username' => array(
                    'required' => true,
                    'min' => 2,
                    'max' => 20,
                    'unique' => 'users'
                ),
                'password' => array(
                        'required' => true,
                        'min' => 6
                    ),
                'password_again' => array(
                        'required' => true,
                        'matches' => 'password'
                    ),
                'name' => array(
                        'required' => true,
                        'min' => 2,
                        'max' => 50
                    )
            ));
            if($validation->passed()) {
                $user = new User();
                $salt = Hash::salt(32);
                try {
                    $user->create(array(
                        'username' => Input::get('username'),
                        'password' => Hash::make(Input::get('password'), $salt),
                        'salt' => $salt,
                        'name' => Input::get('name'),
                        'joined' => date('Y-m-d H:i:s'),
                        'group' => 1
                    )); 
                    Session::flash('home', 'You have been registered and can now log in.');
                    header('Location: index.php');
                } catch(Exception $e) {
                    die($e->getMessage());
                }
            } else {
                foreach($validation->errors() as $error) {
                    echo $error, '<br>';
                }
            }
}
}
?>
