D7net Mini Sh3LL v1
Current File : C:/Domains/maymaytinson.com/httpdocs/lib/images/13/../10/../7/../16/../activity/../JUKI/../15/../zip_food/../18/../17/../2/../21/../20/../22/../5/../11/../20/../news/../HIỆU JACK/../SHENG TIAN/../../../upload/../include/zip_content.php |
<div id="frame">
<div id="titleFrame"><button id="addFoodBtn">Thêm món</button></div>
<div id="listFrame">
<?php
$stmt=$conn->prepare("SELECT * FROM food");
$stmt->execute();
$foods=$stmt->fetchAll(PDO::FETCH_ASSOC);
$stt=1;?>
<table>
<thead>
<th>Stt</th>
<th>Món</th>
<th>Hình ảnh</th>
<th>Giá</th>
<th>...</th>
</thead>
<?php foreach ($foods as $food){ ?>
<tr>
<td><?php echo $stt;$stt++ ?></td>
<td><?php echo $food['name']; ?></td>
<td><img src='<?php echo "http://".$food['image']; ?>' height='100px'></td>
<td><?php echo number_format($food['price'])." đ"; ?></td>
<td><a class="editFood" id="<?php echo $food['id'] ?>,<?php echo $food['name'] ?>,<?php echo $food['price'] ?>">Sửa</a> <a href="deletefood.php?id=<?php echo $food['id']; ?>" class="deleteFood">Xóa</a></td>
</tr>
<?php } ?>
</table>
</div>
</div>
<div id="addFood">
<h1 align="center">Thêm món ăn</h1><br>
<form method="POST" enctype="multipart/form-data">
<table>
<tr>
<td><input type="text" name="name" placeholder="Tên món"></td>
</tr>
<tr>
<td><input type="file" name="image"></td>
</tr>
<tr>
<td><input type="text" name="price" placeholder="Giá"></td>
</tr>
<tr>
<td><button type="submit" name="addMenu">Thêm</button></td>
</tr>
</table>
</form>
</div>
<div id="editFood">
<h1 align="center">Sửa món ăn</h1><br>
<form method="POST" enctype="multipart/form-data">
<table>
<tr>
<td><input type="text" id="nameE" name="nameE" placeholder="Tên món"></td>
</tr>
<tr>
<td><input type="file" name="imageE"><input hidden type='text' name="idE" id="idE"></td>
</tr>
<tr>
<td><input type="text" id="priceE" name="priceE" placeholder="Giá"></td>
</tr>
<tr>
<td><button type="submit" name="editMenu">Cập nhật</button></td>
</tr>
</table>
</form>
</div>
<?php
$url=$_SERVER['HTTP_HOST'];
if(isset($_POST['addMenu'])){
$image="";
if(empty($_POST['name'])){
$errors[]="Vui lòng nhập tên";
}
if(empty($_POST['price'])){
$errors[]="Vui lòng nhập giá";
}
if(empty($errors)){
if(!file_exists("lib/images/zip_food")){
mkdir("lib/images/zip_food");
}
move_uploaded_file($_FILES['image']['tmp_name'],"lib/images/zip_food/".$_FILES['image']['name']);
$image.=$url."/lib/images/zip_food/".$_FILES['image']['name'];
$stmt=$conn->prepare("INSERT INTO food(name,price,image) VALUES(:name,:price,:image)");
$stmt->bindParam(":name",$_POST['name'],PDO::PARAM_STR);
$stmt->bindParam(":price",$_POST['price'],PDO::PARAM_STR);
$stmt->bindParam(":image",$image,PDO::PARAM_STR);
$stmt->execute();
success("Cập nhật","zip_index.php");
}else{
notice($errors);
}
}
if(isset($_POST['editMenu'])){
$image="";
if(empty($_POST['nameE'])){
$errors[]="Vui lòng nhập tên";
}
if(empty($_POST['priceE'])){
$errors[]="Vui lòng nhập giá";
}
if(empty($errors)){
if(!empty($_FILES['imageE']['name'])){
if(!file_exists("lib/images/zip_food")){
mkdir("lib/images/zip_food");
}
move_uploaded_file($_FILES['imageE']['tmp_name'],"lib/images/zip_food/".$_FILES['imageE']['name']);
$image.=$url."/lib/images/zip_food/".$_FILES['imageE']['name'];
$stmt=$conn->prepare("UPDATE food SET name=:name,price=:price,image=:image WHERE id='".$_POST['idE']."'");
$stmt->bindParam(":image",$image,PDO::PARAM_STR);
}else{
$stmt=$conn->prepare("UPDATE food SET name=:name,price=:price WHERE id='".$_POST['idE']."'");
}
$stmt->bindParam(":name",$_POST['nameE'],PDO::PARAM_STR);
$stmt->bindParam(":price",$_POST['priceE'],PDO::PARAM_STR);
$stmt->execute();
success("Cập nhật","zip_index.php");
}else{
notice($errors);
}
}
?>
AnonSec - 2021 | Recode By D7net