<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$db = new SQLite3('./api/.db.db');

$res = $db->query("SELECT * 
				  FROM users 
				  WHERE id='1'");
$row=$res->fetchArray();

if(isset($_POST['submit'])){
$db->exec("UPDATE users SET	username='".$_POST['username']."', 
							password='".$_POST['password']."' 
						  WHERE 
							id='1' ");
$set = $_POST['username'];
setcookie("auth","$set");
header("Location: dns1manager.php");
}
if ($_COOKIE["auth"] = 'admin'){
include ('includes/header.php');

?>
<div class="main-panel">
      <div class="content">
        <div class="container-fluid">
            <div class="col-md-8">
              <div class="card">
                <div class="card-header card-header-warning">
                  <h4 class="card-title">Change Username & Password</h4>
				  <p class="card-category">Do not use- admin admin -or you will keep ending up here!!!</p>
                </div>
                <div class="card-body">
                  <form  method="post">
                      <div class="col-md-6">
                        <div class="form-group">
                          <label class="bmd-label-floating">Username</label>
                          <input type="text" class="form-control" name="username" value="<?=$row['username'] ?>">
                        </div>
                      </div>
                      <div class="col-md-6">
                        <div class="form-group">
                          <label class="bmd-label-floating">Password</label>
                          <input type="text" class="form-control" name="password" value="<?=$row['password']?>">
                        </div>
                      </div>
					<br><button type="submit" name="submit" class="btn btn-warning pull-right">Submit</button>
				</form>
				</div>
              </div>
            </div>
          </div>
      </div>
	 </div>
    <br><br><br>
<?php include ('includes/footer.php');?>
</body>

</html>
<?php }else{header("location:"."dns1manager.php");} ?>