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


if(isset($_REQUEST['edit']))
{
    $ads_id = base64_decode($_REQUEST['edit']);
    $ex = $obj->get_ads_id($ads_id);
    $row = mysqli_fetch_array($ex);
}
if(isset($_POST['update']))
{   
  $adsinfo['ads_id'] = $_POST['ads_id'];
  $adsinfo['ads_title'] = $_POST['ads_title'];
  $adsinfo['ads_desc'] = $_POST['ads_desc'];
  
    $ex = $obj->update_adsinfo($adsinfo);
    echo '<script>window.location="about_details_services.php"</script>';
}

if(isset($_POST['submit']))
{

  $adsinfo['ads_title'] = $_POST['ads_title'];
  $adsinfo['ads_desc'] = $_POST['ads_desc'];
 
    $ex = $obj->insert_adsinfo($adsinfo);
    echo '<script>window.location="about_details_services.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>About Details Services
                <a href="about_details_services.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="ads_id" value="<?php echo $row['ads_id'];?>">
                    
                    <div class="form-group">
                  <label>Title</label>
                  <input type="text" class="form-control" name="ads_title" value="<?php echo $row['ads_title'];?>">
               </div>

                   <div class="form-group">
                        <label>Description</label>
                        <textarea id="w3review" name="ads_desc" rows="6" cols="50" class="form-control"><?php echo $row['ads_desc'];?></textarea>
                     </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 = "about_details_services.php";
</script>

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

