Advertisement
cafreak

functions.class.php #4 [Mike M. tutorial]

Aug 17th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. #region register only
  2.    
  3.         public function create_salt(){
  4.             return bin2hex(mcrypt_create_iv(11, MCRYPT_DEV_URANDOM));
  5.         }
  6.        
  7.         public function register($username, $password){
  8.             //at this very moment usernames are case sensetive!
  9.             $salt = $this->create_salt();
  10.             $password = $this->create_hashed_password($password,$salt);
  11.             global $dbhost, $dbusername, $dbpassword, $dbname;
  12.             $con = new Database($dbhost, $dbusername, $dbpassword, $dbname);
  13.             $query = $con->runQuery("INSERT INTO `users` VALUES('','".$username."','".$password."','".$salt."')");
  14.             if($query){
  15.                 return true;
  16.             }else{
  17.                 return false;
  18.             }
  19.         }
  20.        
  21.     #end
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement