<?php 
error_reporting(0);
include ('includes/header.php');

$table_name = 'intro';

$db->exec("CREATE TABLE IF NOT EXISTS {$table_name}(id INTEGER PRIMARY KEY,url TEXT)");

$rows = $db->query("SELECT COUNT(*) as count FROM {$table_name}");
$row = $rows->fetchArray();
$numRows = $row['count'];
if ($numRows == 0){
	$db->exec("INSERT INTO {$table_name}(url) VALUES('')");
}

$res = $db->query("SELECT * FROM {$table_name} WHERE id='1'");
$rowU=$res->fetchArray();

if(isset($_POST['submit'])){
	$db->exec("UPDATE {$table_name} SET	url='{$_POST['url']}' WHERE id='1' ");
	header("Location: intro.php");
}

?>
<div class="container text-center text-dark mt-5">
  <div class="row">
    <div class="col-lg-4 d-block mx-auto mt-5">
      <div class="row">
        <div class="col-xl-12 col-md-12 col-md-12">
          <div class="card">
            <div class="card-body wow-bg" id="formBg">
              <h3 class="colorboard">intro mp4 url</h3>
              <form  method="post">
                <div class="input-group mb-3"> <input type="text" class="form-control textbox-dg" placeholder=".mp4 url" name="url" value="<?=$rowU['url'] ?>" > </div>
                <div class="row">
                  <div class="col-12"> <button type="submit" name="submit" class="btn btn-primary btn-block logn-btn">Submit</button> </div>
                </div>
              </form>
              <video width="320" height="240" autoplay>
  <source src="<?=$rowU['url'] ?>" type="video/mp4">
  Your browser does not support HTML video.
</video>
              
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<?php include ('includes/footer.php');?>