Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Repository_User {
- public function Login($Username, $Password) {
- global $DB;
- $Username = $DB->safe_string($Username);
- $Password = $DB->safe_string($Password);
- $DB->query("SELECT ID, Username, Email, Password FROM users WHERE Username = '{$Username}'");
- $User = new User($DB->next_record());
- if(password_verify($Password, $User->Password)) {
- $_SESSION['User'] = serialize($User);
- return true;
- } else return "Invalid Username / Password";
- }
- public function Register($Params) {
- global $DB;
- $Keys = array();
- $Values = array();
- $Params['Password'] = $Password_Hash = password_hash($Params['Password'], PASSWORD_BCRYPT);
- foreach($Params as $Key => $Value) {
- $Keys[] = $Key;
- $Values[] = $DB->safe_string($Value);
- }
- $Key = implode(", ", $Keys);
- $Value = implode("', '", $Values);
- $DB->query("INSERT INTO users ({$Key}) VALUES('{$Value}')");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement