Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once('Connect.php');
- class LoginModel extends Connect{
- private $username;
- private $password;
- public function __construct($username, $password) {
- $this->username = $username;
- $this->password = $password;
- }
- public function getUser() {
- db();
- }
- public function login() {
- }
- }
- $loginModel = new LoginModel($_POST['displayName'], $_POST['password']);
- $loginModel->getUser();
- class Connect {
- private $servername;
- private $username;
- private $password;
- public function __construct() {
- $this->servername = 'localhost';
- $this->username = 'root';
- $this->password = '';
- }
- public function db() {
- try {
- $conn = new PDO("mysql:host=$this->servername;dbname=test", $this->username, $this->password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }catch(PDOException $e) {
- die("Connection failed" . $e->getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement