Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Dbh {
- private $servername;
- private $username;
- private $password;
- private $dbname;
- private $charset;
- public function connect() {
- $this->servername = 'localhost';
- $this->username = 'root';
- $this->password = 'exh05t9a';
- $this->dbname = 'hash';
- $this->charset = 'utf8';
- try {
- $dsn = "mysql:host=".$this->servername.";dbname=".$this->dbname.";charset=".$this->charset;
- $pdo = new PDO($dsn, $this->username, $this->password);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- return $dpo;
- } catch (PDOExeption $e) {
- echo "Connection failed: ".$e->getMessage();
- }
- }
- }
- ?>
- <?php
- class Password extends Dbh {
- public function getUserPassword() {
- $stmt = $this->connect()->query("SELECT password FROM users");
- while ( $row = $stmt->fetch() ) {
- $password = $row['password'];
- return $password;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement