<?php
$page_title = "Settings";
include("includes/header.php");

$qry = "SELECT * FROM tbl_settings where id='1'";
$result = mysqli_query($mysqli, $qry);
$settings_row = mysqli_fetch_assoc($result);
$count = $result->num_rows;

if (isset($_POST['submit']) && PURCHASE == '') {

    if (
        empty(validate_input($_POST['user_agent']))
    ) {
        $_SESSION['msg'] = "15";
        $_SESSION['class'] = 'error';
        header("Location:user_agent_settings.php");
        exit;
    }

    $data = array(
        'user_agent'  =>  validate_input($_POST['user_agent'])
    );

    $settings_edit = Update('tbl_settings', $data, "WHERE id = '1'");

    $_SESSION['msg'] = "11";
    header("Location:user_agent_settings.php");
    exit;
}
?>
<main id="main" class="main">
    <section class="section">
        <div class="row  g-3">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body g-3"><br>
                        <div class="pagetitle mb-5">
                            <h1><?php _e($page_title); ?></h1>

                        </div>
                        <form class="row g-3" action="" name="settings_from" method="post" class="form form-horizontal" enctype="multipart/form-data">
                            <br><br>
                            <div class="col-12">
                                <label for="inputNanme4" class="form-label">App Name</label>
                                <input type="text" class="form-control" name="user_agent" id="floatingName" value="<?php _e($settings_row['user_agent']); ?>" class="form-control">
                            </div>
                            <div class="text-center">
                                <button type="submit" name="submit" class="btn button btn-primary <?php _e(PURCHASE); ?>">Save</button>
                                <button type="reset" class="btn btn-secondary">Reset</button>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>
    </section>

</main><!-- End #main -->
<?php include("includes/footer.php"); ?>