<?php 
require '../assets/config-data.php';

$botxt = mysqli_real_escape_string($data, $_REQUEST['panduan-page-text']);
$img = mysqli_real_escape_string($data, $_REQUEST['img-panduan']); 
$desc = mysqli_real_escape_string($data, $_REQUEST['desc']);
$id = mysqli_real_escape_string($data, $_GET['row']);

$string = mysqli_real_escape_string($data, $_REQUEST['title-panduan']);
        $string2 = strtolower($string);
        $string3 = str_replace(" ", "-", $string2);
        $string4 = str_replace(array('%', '"', '<', '>', '/', '{', '}', '*', '&', '#', '@', '!', '?', '^', '(', ')', '+', '=', '`', '~', '.', ',', '[', ']', '|', '\\' ), '', $string3);
        $string7 = '';
        if(strlen($string4) > 2){
            $string5 = substr($string4, 0, 20);
            $string6 = substr($string5, -1);
            if($string6 == '-') {
                $string7 = substr($string5, 0, -1);
            } else {
                 $string7 = $string4;
            }
        } else {
            $string7 = $string4;
        }

        $tt = $string7 . '-'. date("h-i-s-Y-m-d");
        echo '<div style="display: none;">'
                .$tt.
            '</div>';

$updatestatus = "UPDATE panduan_post SET title_panduan = '$string', short_dec_panduan = '$desc', title_slug_panduan = '$tt', thumbnail_panduan = '$img', content_panduan = '$botxt' WHERE id = '$id'";
$bindstats = mysqli_query($data, $updatestatus);

if($bindstats) {
    echo '
    <script>
        alert("Panduan Successfully Change!!");
        window.location.href = "../dashboard.php?hal=panduan";
    </script>
    ';

} else {

    echo '
    <script>
        alert("ERROR on Change!!");
        window.location.href = "../dashboard.php?hal=panduan";
    </script>
    ';

}

?>