<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$db = new SQLite3('./.db.db');

$res = $db->query("SELECT * 
				  FROM notifications 
				  WHERE id='".$_GET['update']."'");
$row=$res->fetchArray();

if(isset($_POST['submit'])){
$db->exec("UPDATE notifications SET  title='".$_POST['title']."', 
								description='".$_POST['description']."',
								backdrop='".$_POST['backdrop']."',
								reference='".$_POST['reference']."' 
						  WHERE 
							  id='".$_POST['id']."'");
$db->close();
header("Location: notifications.php");
}

?>
<!doctype html>
<html lang="en">
  <head>
    <title>Admin Notifications</title>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />

<style>
body
{
background-color: black;
color: white;
margin: 0 auto;
}
.block {
  display: block;
  width: 20%;
  border: none;
  color: black;
  padding: 14px 28px;
  font-size: 18px;
  cursor: pointer;
  text-align: center;
  margin: 0 auto;

}

.block:hover {
  background-color: black;
  color: white;
}

</style>
<body>
<br><br><br>
      <div class="container">
	  <div class="col-md-8">
      <div class="card bg-dark text-white ">
        <div class="card-header">
          <h4 class="card-title">Add Notification</h4>
                </div>
                <div class="card-body">
                  <form  method="post">
                        <div class="form-group">
                          <label>Title</label>
						   <input type="hidden" name="id" value="<?=$row['id'] ?>">
                          <input type="text" class="incol form-control" name="title" value="<?=$row['title'] ?>">
                        </div>
                        <div class="form-group">
                          <label>Description</label>
                          <input type="text" class="incol form-control" name="description" value="<?=$row['description'] ?>">
                        </div>
                        <div class="form-group">
                          <label>Notification Banner</label>
                          <input type="text" class="incol form-control" name="backdrop" value="<?=$row['backdrop'] ?>">
                        </div>
                        <div class="form-group">
                          <label>Reference Url</label>
                          <input type="text" class="incol form-control" name="reference" value="<?=$row['reference'] ?>">
                        </div>
					<br><button type="submit" name="submit" class="btn block pull-right">Submit</button>
				</form>
				</div>
              </div>
            </div>
			</div>
    <br><br><br>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://unpkg.com/popper.js@1.12.6/dist/umd/popper.js" integrity="sha384-fA23ZRQ3G/J53mElWqVJEGJzU0sTs+SvzG8fXVWP+kJQ1lwFAOkcUOysnlKJC33U" crossorigin="anonymous"></script>
	  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>

</html>