<?php 
    include("../db.php");
    if($_POST){

        if(isset($_FILES["image"]["name"]) && !empty($_FILES["image"]["name"])){
    		$lfilename = basename($_FILES['image']['name']);
    		$lext = strtolower(substr($lfilename, strrpos($lfilename, '.')+1));
    		$lnewfile=md5(microtime()).".".$lext;
    		echo "$lnewfile";
    		if(move_uploaded_file($_FILES['image']['tmp_name'],"../uploads/aboutus/".$lnewfile)){
    		    echo "hello";
    		    $_POST['image'] = $lnewfile;
    		}
    	}
    
   

        $db->updateAry("about_us", $_POST, "where id='1'");
        
        header("Location: about_us");
    }
?>

<!DOCTYPE html>
<html>
<head>
    <title>Admin Dashboard</title>
    <?php include("meta.php"); ?>

</head>
<body> 
 
<?php include("header.php"); ?>

<?php include("sidebar.php"); 

    $data = $db->getRow("select * from about_us where id='1' ");

?>

<div class="main">
    
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="content-div">
                    <h2>ABOUT US</h2>
                    
                    <form action="" method="post" enctype="multipart/form-data">
                        <div class="form-row row">
                            <div class="col-md-2"><label>Content</label></div>
                            <div class="col-md-10"><textarea id="content" name="content" rows="12" style="height: 217px;" cols="110" ><?php echo $data['content'];?>
                        </textarea></div>
                        </div>
                       
                        <div class="form-row row">
                            <div class="col-md-2"><label>Choose Image</label></div>
                            <div class="col-md-10"><input type="file" name="image" class="form-control" />
                                <?php if($data["image"]!=""){ ?>
                                    <img src="../uploads/aboutus/<?php echo $data["image"]; ?>" style="width: 820px;">
                                <?php } ?>
                            </div>
                        </div>
                       <br>
                        <div class="form-row form-check text-center"><input type="submit" class="btn btn-primary" value="Save Changes"></div>
                    </form>
                    
                </div>

            </div>   
        </div>
    </div>
    
</div>
     
</body>
</html> 
