public function __construct() { $dbinfo = MyDatabase::getConnectionDetails(); $host = $dbinfo["host"]; $database = $dbinfo["database"]; $username = $dbinfo["username"]; $password = $dbinfo["password"]; $db = new MyDatabase($host, $database, $username, $password); $this->conn = $db->get_connection(); }
<input type="submit" name="submit" value="submit" class="btn btn-primary"/> </form> </div> </div> </div> </div> <?php if (isset($_POST["submit"])) { $username = trim($_POST["username"]); $password = trim($_POST["password"]); if (strlen($username) == 0 || strlen($password) == 0) { echo '<script type="text/javascript">' . '$(".error-message").removeClass("hidden");' . '$(".error-message p strong").html("You\'ve got an empty field");' . 'setTimeout(function() {$(".error-message").hide();}, 3000);' . '</script>'; return; } $dbinfo = MyDatabase::getConnectionDetails(); $host = $dbinfo["host"]; $database = $dbinfo["database"]; $db_username = $dbinfo["username"]; $db_password = $dbinfo["password"]; $db = new MyDatabase($host, $database, $db_username, $db_password); $conn = $db->get_connection(); $query = "SELECT * FROM authentication WHERE username = ?"; $stmt = $conn->prepare($query); $stmt->bindParam("1", $username); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); /*echo(var_dump($result));*/ if ($result == false) { echo '<script type="text/javascript">' . '$(".error-message").removeClass("hidden");' . '$(".error-message p strong").html("Your username or password is wrong");' . 'setTimeout(function() {$(".error-message").hide();}, 3000);' . '</script>'; } else {