<?php  session_start(); error_reporting(0); ?>
<?php if(!isset($_SESSION['j_admin']) && !isset($_SESSION['j_admin'])){ 
    $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); header('location:../login/?url='.$url.'');  
} ?>
<!doctype html>
<html lang="en"> 
<head>
	<?php
    require_once("../j_conn/url.php");
    require_once("../j_conn/dbc.php");
    require_once("../j_incs/functions.php");
    $page_name="Edit Testimonials";
    $page_desc="$page_name";
    $page_img="".$dir."j_files/j_img/logo/logo-meta.png";
    $page_author="$company";
    $page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
    $page_url="".$dir."testimonials-edit/";
    require_once("../j_incs/metas.php");
    require_once("../j_incs/scripts-top.php");
    ?>
</head>
<body>
    
    <div class="app">
        <div class="layout">
            <?php 
            require_once("../j_incs/header.php");
            require_once("../j_incs/nav.php");
            ?>
            <!-- Page Container START -->
            <div class="page-container">
                

                <!-- Content Wrapper START -->
                <div class="main-content">
                    <div class="container-fluid">
                        <div class="">
                            <div class="col-md-11 mx-auto">
                                <div class="page-header">
									<?php /*<h2 class="header-title"><?php echo $page_name; ?></h2>*/ ?>
									<div class="header-sub-title">
										<nav class="breadcrumb breadcrumb-dash">
											<a href="<?php echo $dir; ?>" class="breadcrumb-item"><i class="anticon anticon-dashboard m-r-5"></i>Dashboard</a>
											<!--<a class="breadcrumb-item" href="#"> </a>-->
											<span class="breadcrumb-item active"><?php echo $page_name; ?></span>
										</nav>
									</div>
								</div>
                            </div>
                        </div>
                    </div>
                     
                    <div class="container-fluid">
						<div class="">
							<div class="col-md-11 mx-auto">
								<div class="tab-content m-t-15">
									<div class="tab-pane fade show active" id="tab-account">


										<div class="">
											<div class="card-header">
												<h4>Edit Testimonials</h4>
											</div>
											<div class="">
											
												
												
												
												<?php 
												$ref = RMC($_GET['ref']);
												$sql4="SELECT  * from j_testimonials WHERE j_id='".$ref."' AND j_deleted < 1"; //check 
												$result4 = runSQL($sql4);
												$data4 = mysqli_fetch_array($result4);
												$ref = $data4['j_id'];
												$name = $data4['j_name'];
												$msg = $data4['j_msg'];
												?>
												<form method="POST" action="" id="form">
													<div class="form-group" style="display:none;">
														<input value="<?php echo $ref; ?>" type="text" class="form-control rMe" name="ref"/>
													</div>
													
													<div class="row mb-50 ">

													<div class="form-group mb-50 col-lg-6">
														<label class="text-bold-600" for="name"> User Full Name </label>
														<input value="<?php echo $name; ?>" type="text" class="form-control" name="name" placeholder="Enter Name">
													</div>


													<div class="form-group mb-50 col-lg-12">
														<label class="text-bold-600" for="msg">Message</label>
														<textarea rows="5" type="text" class="form-control j_field" name="msg" placeholder="Enter Message"><?php echo $msg; ?></textarea>
													</div>
												
													<div class="form-group col-lg-6">
														<label class="text-bold-600" for="old_password"> Enter your Password</label>
														<input type="password" class="form-control rMe" name="old_password" placeholder="Enter Password">
													</div>

													</div>
													
											
													<div class="form-group">
														<button id="submit"  name="submit" class="btn btn-primary btn-block">
															UPDATE
														</button>
													 </div>
														
												</form>
												<div id="formresult"></div>
												
												
												
												
											
												
												
											</div>
										</div>

									</div>
								</div>
							</div>
						</div>
					</div>
                </div>
                <!-- Content Wrapper END -->

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

            </div>
            <!-- Page Container END -->
        </div>
    </div>
    
    
    <?php
    require_once("../j_incs/scripts-bottom.php");
    ?>
    <script>
        var form = "#form";
        var button = "#submit";
        var button_val = $(button).html();
        var result = "#formresult";
        $(form).on('submit',(function(e) {
        e.preventDefault();
        $(button).attr('disabled', '');
        $(button).html("<i class='anticon anticon-loading'></i> Processing");
        $(result).html("<div class='alert alert-warning'> Taking too long? <a href=''>Reload </a></div>");
         $.ajax({
        url: "save.php",
        type: "POST",
        data: new FormData(this),
        contentType: false,
        cache: false,
        processData:false,
        success: function(data)
        {
        if(data){
         $(button).removeAttr('disabled');
        $(button).html(button_val);
        $(result).html(data);
        }else{
        $(result).html("Error occurred.");
        $(button).removeAttr('disabled');
        $(button).html(button_val);
        }
        }
        });
        }));
        </script>
   
</body>
</html>