<?php
require_once("header.php");
require_once("menu.php");


if(isset($_REQUEST['edit']))
{
    $id = base64_decode($_REQUEST['edit']);
    $ex = $obj->get_why_us_points_id($id);
    $row = mysqli_fetch_array($ex);
}
if(isset($_POST['update']))
{   
    $update_why_us_points['id'] = $_POST['id'];
    $update_why_us_points['title'] = $_POST['title'];
    $update_why_us_points['subtitle'] = $_POST['subtitle'];
	 
       
     
    $ex = $obj->update_why_us_points($update_why_us_points);
    echo '<script>window.location="why_us_points.php"</script>';
}

if(isset($_POST['submit']))
{
	$why_uspoint['title'] = $_POST['title'];
	$why_uspoint['subtitle'] = $_POST['subtitle'];
	
    $ex = $obj->insert_why_us_points($why_uspoint);
    echo '<script>window.location="why_us_points.php"</script>';
}

?>

<div id="layoutSidenav_content">
<main class="mt-4">
    <div class="container-fluid">
        
        <div class="card mb-4">
            <div class="card-header">
                <i class="fas fa-check-square mr-1"></i>Why Us Points
                <a href="why_us_points.php" class="btn btn-primary btn-sm float-right">Back</a>
            </div>
            <div class="card-body">
                <form method="post" name="frm" id="frm" enctype="multipart/form-data">
                   <input type="hidden" name="id" value="<?php echo $id;?>">
                    
                    
					
					<div class="form-group">
                        <label>Title</label>
                        <input type="text" class="form-control" name="title" required value="<?php echo $row['title'];?>">
                    </div>
                    <div class="form-group">
                        <label>Subtitle</label>
                        <input type="text" class="form-control" name="subtitle" required value="<?php echo $row['subtitle'];?>">
                    </div>
					
                    <?php if(isset($_REQUEST['edit']))
                    { ?> 
                        <button type="submit" class="btn btn-primary" name="update">Update</button>
                    <?php } 
                    else
                    { ?>
                        <button type="submit" class="btn btn-primary" name="submit">Submit</button>
                    <?php } ?>
                </form> 
            </div>
        </div>
    </div>
</main>

<script>
    var url = "service.php";
</script>

<?php require_once("footer.php");?>

