<?php include('session.php'); ?>
<!DOCTYPE html>
<html lang="en">
  <head>
	<title>ECIMS ADMIN | UPDATE HELP</title>
    <?php include('includes/head.php'); ?>
  </head>
  <body>
    <div class="container-scroller">
      <div class="horizontal-menu">
        <?php include('includes/header.php'); ?>
      </div>
      <div class="container-fluid page-body-wrapper">
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title"> Update Help Content </h3>
            </div>
            <div class="row">
              <div class="col-12 grid-margin stretch-card">
                <div class="card">
                  <div class="card-body">
                      <?php $err = $msg = '';
							if(isset($_POST['submit'])) {
								$title = mysqli_real_escape_string($conn, $_POST['title']);
								$content = mysqli_real_escape_string($conn, $_POST['content']);
							$insert = $conn->query("UPDATE aboutus SET title='".$title."',content='".$content."' WHERE id='2'");
							if($insert){
								$msg = 'Data Added Successfully.';
							} else {
								$err = $conn->error;
							}
						}
						if(!empty($err)){
						  echo "
							<div class='alert alert-danger alert-dismissible'>
							  <h4><i class='fa fa-warning'></i> Error!</h4>
							  ".$err."
							</div>
						  ";
						}
						if(!empty($msg)){
						  echo "
							<div class='alert alert-success alert-dismissible'>
							  <h4><i class='fa fa-check'></i> Success!</h4>
							  ".$msg."
							</div>
						  ";
						}
						$about = $conn->query("SELECT * FROM aboutus WHERE id='2'")->fetch_assoc();
						?>
                    <form class="forms-sample" method="POST">
                      <div class="form-group">
                        <label for="title">Title</label>
                        <input type="text" class="form-control" required name="title" id="title" value="<?php echo $about['title']; ?>" placeholder="Title">
                      </div>
                      <div class="form-group">
                        <label for="exampleTextarea1">Content</label>
                        <textarea class="form-control ckeditor" id="exampleTextarea1" rows="7" name="content"><?php echo $about['content']; ?></textarea>
                      </div>
                      <button type="submit" name="submit" class="btn btn-primary me-2">Update</button>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
		  <?php include('includes/footer.php'); ?>
        </div>
      </div>
    </div>
    <?php include('includes/foot.php'); ?>
  </body>
</html>