Mixshows.
This commit is contained in:
parent
8b4dfe0c0c
commit
ef4eedcd6e
12 changed files with 493 additions and 23 deletions
50
classes/User.php
Normal file
50
classes/User.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Random\RandomException;
|
||||
|
||||
Class User{
|
||||
|
||||
private $db;
|
||||
private $id;
|
||||
private $username;
|
||||
private $email;
|
||||
private $location;
|
||||
private $bio;
|
||||
private $created;
|
||||
private $updated;
|
||||
private $verified;
|
||||
private $role;
|
||||
private $img;
|
||||
private $api_key;
|
||||
|
||||
public function __construct($db){
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RandomException
|
||||
*/
|
||||
public function newUser($username, $password, $email){
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
$password2 = password_hash($password, PASSWORD_DEFAULT);
|
||||
$this->password = $password2;
|
||||
|
||||
$this->location = "";
|
||||
$this->bio = "";
|
||||
$this->created = date('Y-m-d H:i:s');
|
||||
$this->updated = date('Y-m-d H:i:s');
|
||||
$this->verified = 0;
|
||||
$this->role = "user";
|
||||
$this->img = "";
|
||||
$this->api_key = bin2hex(random_bytes(32));
|
||||
|
||||
$stmt = $this->db->prepare("INSERT INTO users (username, password, email, img) VALUES (?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssss", $this->username, $this->password, $this->email, $this->img);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue