-1

i developed mvc with php and mysql and pdo in hosting the site appeared this problem in the admin control panel i created its in the login controller

the problem is as shown in browser

Parse error: syntax error, unexpected '[' in /home/trustlabseg/public_html/test/app/C_LoginController.php on line 21

i searched for all the same error in here and its not like that no one solve my problem

the code is

  $password = crypt($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]);

    $rules = [
                    "username" => "checkReguired|checkStrings",
                    "password" => "checkReguired"
     ];

when i delete the last line the page load but still canot loging please little help here and thanks alot

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • Please use PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html) to handle password security. If you're using a PHP version less than 5.5 you can use the `password_hash()` [compatibility pack](https://github.com/ircmaxell/password_compat). – Jay Blanchard Dec 08 '15 at 19:19

1 Answers1

0

Use array() for older PHP versions. Additionally, it is spelled "required" (as in to require).

$password = crypt($_POST['password'], PASSWORD_BCRYPT, array('cost' => 12));
$rules = array("username" => "checkRequired|checkStrings", "password" => "checkRequired");
Jan
  • 42,290
  • 8
  • 54
  • 79