<!DOCTYPE html>
<html lang="vi">

<head>
    <?php require_once('head.php');?>
    <title>AdminLTE 3 | Dashboard</title>
    <?php require_once('nav.php');?>
</head>

<?php
if(isset($_POST['submit'])){
$tieude = $_POST['nameproduct'];
$mota = $_POST['mota'];
$image = $_POST['image'];
$setup = $_POST['setup'];
$code = $_POST['code'];
$sql = $_POST['sql'];
$taikhoan = $_POST['taikhoan'];
$matkhau = $_POST['matkhau'];
$price = $_POST['price'];
if($tieude == "" || $mota == "" || $image == "" || $setup == ""){
 echo '<script type="text/javascript">if(!alert("Vui Lòng Nhập Đầy Đủ Thông Tin! !")){window.history.back().location.reload();}</script>';    
} else {
                           $cloudstorevn = mysqli_query($ketnoi, "INSERT INTO `Templates` (`id`, `name`, `mota`, `image`, `price`, `url_code`, `url_sql`, `setup`, `taikhoan`, `matkhau`) VALUES (NULL, '$tieude', '$mota', '$image', '$price', '$code', '$sql', '$setup', '$taikhoan', '$matkhau')");
                           if($cloudstorevn){
                           echo '<script type="text/javascript">if(!alert("Cập nhật thành công !")){window.history.back().location.reload();}</script>';
                          
                           } else {
                           echo '<script type="text/javascript">if(!alert("Có lỗi xảy ra !")){window.history.back().location.reload();}</script>'; 
                           }
}
}
?>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                        <div class="col-sm-6">
                            <h1 class="m-0">Add Mẫu Web</h1>
                        </div><!-- /.col -->
                        <div class="col-sm-6">
                            <ol class="breadcrumb float-sm-right">
                                <li class="breadcrumb-item"><a href="#">Home</a></li>
                                <li class="breadcrumb-item active">Add Mẫu Web</li>
                            </ol>
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.container-fluid -->
            </div>
            <!-- /.content-header -->

            <!-- Main content -->
            <section class="content">
                <div class="container-fluid">
                    <!-- Small boxes (Stat box) -->
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card">
                                <div class="card-header">
                                    <h3 class="card-title">Add Mẫu Web</h3>
                                </div>
                                <!-- /.card-header -->
                                <div class="card-body">
                                    <form role="form" action="" method="post">
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">TITLE</label>
                                            <input type="text" name="nameproduct" class="form-control" value="<?=$cloudstorevn['name'];?>" placeholder="Tên Sản Phẩm">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">IMG</label>
                                            <input type="text" class="form-control" name="image" placeholder="Ảnh Mô Tả" value="<?=$cloudstorevn['image'];?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">GIÁ</label>
                                            <input type="number" class="form-control" name="price" placeholder="Giá Bán" value="<?=$cloudstorevn['name'];?>" >
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Mô tả</label>
                                            <textarea type="text" class="form-control" name="mota" placeholder="Nhập Mô Tả Sản Phẩm" value="<?=$cloudstorevn['mota'];?>" rows="4" cols="50"></textarea>
                                        </div>
                             <div class="form-group">
                                            <label for="exampleInputEmail1">LOẠI</label>
                                             <select class="form-control" placeholder="" name="setup">
                            <option value="<?=$cloudstorevn['setup'];?>"> <?=$cloudstorevn['setup'];?> </option>
                            <option value="auto"> Tạo Tự Động </option>
                            <option value="cloudstorevn"> Duyệt Tay </option> 
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">url_code</label>
                                            <input type="text" class="form-control" placeholder="Liên Kêt Chứa ZIP" value="<?=$cloudstorevn['url_code'];?>"  name="code">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">sql</label>
                                            <input type="text" class="form-control" placeholder="Liên Kêt Chứa SQL" name="sql" value="<?=$cloudstorevn['url_sql'];?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">taikhoan</label>
                                            <input type="text" class="form-control" placeholder="Nếu Có Thì Nhập" name="taikhoan" value="<?=$cloudstorevn['taikhoan'];?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">matkhau</label>
                                            <input type="text" class="form-control" placeholder="Nếu Có Thì Nhập" name="matkhau" value="<?=$cloudstorevn['matkhau'];?>">
                                        </div>
                                        
                                        <button type="submit" name="submit" class="btn btn-primary">Lưu</button>
                                    </form>
                                </div>
                                <!-- /.card-body -->
                                <div class="card-footer clearfix">
                                    <a href="dsmauweb.php" class="btn btn-info">Về DS Mẫu Web</a>
                                </div>
                                <!-- /end.card-body -->
                            </div>
                            <!-- /.card -->
                        </div>
                    </div>
                    <!-- /.row -->
                </div><!-- /.container-fluid -->
            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->


        <!-- Control Sidebar -->
        <aside class="control-sidebar control-sidebar-dark">
            <!-- Control sidebar content goes here -->
        </aside>
        <!-- /.control-sidebar -->
    </div>
    <!-- ./wrapper -->

    <?php require_once('foot.php');?>
</body>

</html>