Здравствуйте.
При редактировании данных передаются пустые данные. Как сделать, чтобы, например, если не выбран файл для загрузки, значение не изменялось в базе данных.
<?php
session_start();
include_once '../inc/db.php';
include_once 'header.php';
$id = $_GET['id'];
$admin = new db();
$game_ed = $admin->game_page($id);
$catid = $_GET['catid'];
if($id>0){
$game_edit = mysqli_fetch_array($game_ed);
echo $game_edit['name'];
$categ = $game_edit['categ'];
?>
<form method="POST" enctype="multipart/form-data">
<center>
Name: <input type="text" name="name" size="12" value="<?php echo $game_edit['name'] ?>">
</center>
<center>Text <input name="text" size="200" value="<?php echo $game_edit['desc'] ?>"> </input> </center>
<center> Image : <input type="file" name="orig" size="12" value="<?php echo $game_edit['image'] ?>"> </center>
<center> Slide : <input type="file" name="sl1" size="12"> <input type="file" name="sl2" size="12"> <input type="file" name="sl3" size="12"> </center>
<center> Background <input type="file" name="back" size="12" value="<?php echo $game_edit['bg_game'] ?>"> </center>
<center>Background Color <input type="text" name="bg_color" size="12" value=" <?php echo $game_edit['bg_color'] ?> "> </center>
<center>Logo <input type="file" name="logo" size="12" value=" <?php echo $game_edit['logo'] ?>"> </center>
<center> URL <input type="text" name="url" size="12" value="<?php echo $game_edit['url'] ?> "> </center>
<center><input type="submit" name="sub" value="send"></center>
</form>
<?php
if($_FILES){
if(true === empty($_POST['name']))
{
}
else {
$name = $_POST['name'];
}
if(true === empty($_POST['text'])){
}
else {
$text = $_POST['text'];
}
if(true === empty($_FILES['orig']['name'])){
}
else {
$image = $_FILES['orig']['name'];
}
if(true === empty($_FILES['back']['name'])){
}
else {
$background = $_FILES['back']['name'];
}
if(true === empty($_POST['bg_color'])){
}
else {
$back_color = $_POST['bg_color'];
}
if(true === empty($_FILES['logo']['name'])){
}
else {
$logo = $_FILES['logo']['name'];
}
$sl1 = $_FILES['sl1']['name'];
$sl2 = $_FILES['sl2']['name'];
$sl3 = $_FILES['sl3']['name'];
$back_color = $_POST['bg_color'];
if(true === empty($_POST['url'])){}
else {
$url = $_POST['url'];
}
if(isset($_POST['sub'])){
move_uploaded_file($_FILES['orig']['tmp_name'],"../image/game/game_img/".$image);
move_uploaded_file($_FILES['back']['tmp_name'],"../image/game/bg/".$background);
move_uploaded_file($_FILES['sl1']['tmp_name'],"../image/game/slider_game/".$sl1);
move_uploaded_file($_FILES['sl2']['tmp_name'],"../image/game/slider_game/".$sl2);
move_uploaded_file($_FILES['sl3']['tmp_name'],"../image/game/slider_game/".$sl3);
move_uploaded_file($_FILES['logo']['tmp_name'],"../image/game/slider_game/".$logo);
$admin->updategame($id,$name,$text,$image,$background,$back_color,$logo,$categ,$url);
}
}
}
else {
$game_li = $admin->game($catid);
while ($game_list = mysqli_fetch_array($game_li)){
echo "<a href='?id=".$game_list['id']."'>".$game_list['name']."</a>";
}
}