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

$table_name = 'textads';
$page = "text_ads.php";


$data = ['adstext' => 'Hi, those who are connected with my service are able to experience the bliss of heaven in this world. This is very useful. Hi, those who are connected with my service are able to experience the bliss of heaven in this world. This is very useful. Hi, those who are connected with my service are able to experience the bliss of heaven in this world. This is very useful. Hi, those who are connected with my service are able to experience the bliss of heaven in this world. This is very useful.','status' => '1'];

$db->insertIfEmpty($table_name, $data);

//table call
$rowU = $db->select($table_name, '*', '', '');

if(isset($_POST['submit'])){
	unset($_POST['submit']);
	$updateData = $_POST;
	$db->update($table_name, $updateData, 'id = :id',[':id' => 1]);
	echo "<script>window.location.href='". $page."?status=1'</script>";
}

?>

        <div class="col-md-6 mx-auto ctmain-table">
            <div class="card-body">
                <div class="card text-white ctcard">
                    <div class="card-header card-header-warning">
                        <center>
                            <h2><i class="icon icon-bullhorn"></i> Text Ads</h2>
                        </center>
                    </div>
                    <div class="card-body ctcard">
                        <div class="col-12">
                            <h3>Text Ads Details</h3>
                        </div>
                            <form method="post">
								<div class="form-group ctinput">
									  <label class="form-group form-float form-group-lg">Current Status</label>
									  <select class="form-control" id="select" name="status">
										  <option value="0" <?=$rowU[0]['status']=='0'?'selected':'' ?>>Off</option>
										  <option value="1" <?=$rowU[0]['status']=='1'?'selected':'' ?>>On</option>
									  </select>
								</div>
                                <div class="form-group ctinput">
                                    <label class="form-label " for="package">Message</label>
                                        <input class="form-control"  name="adstext" value="<?=$rowU[0]['adstext'] ?>" type="text"/>
                                </div>
                                <div class="form-group ctinputform-group">
                                    <center>
                                        <button class="btn btn-info " name="submit" type="submit">
                                            <i class="icon icon-check"></i> Submit
                                        </button>
                                    </center>
                                </div>
                            </form>
                    </div>
                </div>
            </div>
        </div>

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