0

これは私のコードです

$id = $_POST['id'];
$category = $_POST['category'];
$title = $_POST['title'];
$short_content = $_POST['short_content'];
$long_content = $_POST['long_content'];
$date = $_POST['date'];
$lang = $_POST['language'];
//echo $id." ".$category." ".$title." ".$short_content." ".$lang." ".$date;

if(empty($id)){
    echo "<h3 align=\"center\">Please fill ID</h3>";
}

if(empty($category)){
    echo "<h3 align=\"center\">Please fill Category</h3>";
}

if(empty($title)){
    echo "<h3 align=\"center\">Please fill Title</h3>";
}

if(empty($date)){
    echo "<h3 align=\"center\">Please fill Date</h3>";
}

if(empty($lang)){
    echo "<h3 align=\"center\">Please fill Lang</h3>";
}

if(!empty($_FILES['img']['name'])){
    $extension = end(explode(".",$_FILES['img']['name']));
    //echo "file format: ".$extension."<br>";
    $name = $_FILES['img']['name'];
    $size = $_FILES['img']['size'];

    if(file_exists("views/admin/uploads/".$name)){
        echo "<h3 align=\"center\">".$_FILES['img']['name']." exists</h3>
        <a href=".$_SERVER['HTTP_REFERER']."><h3 align=\"center\">Go back</h3></a>";
        return false;
    }

    if($extension != "jpg" && $extension != "png" && $extension != "gif" && $extension != "JPG"){
        echo "<h3 align=\"center\">File with format: ".$extension." is not aviable to upload</h3>
        <a href=".$_SERVER['HTTP_REFERER']."><h3 align=\"center\">Go back</h3></a>";
        return false;
    }
}

if(!empty($id) && !empty($category) && !empty($title) && !empty($date) && !empty($lang)){
    $query = mysql_query("UPDATE `news` SET `id`='$id', category`='$category',`title`='$title',`img`='$name',`short_content`='$short_content',`content`='$long_content',`date`='$date',`lang`='$lang' WHERE `id`='$id'");
    move_uploaded_file($_FILES['img']['tmp_name'],"views/admin/uploads/".$name);
    echo "<h2 align=\"center\">Successfully updated!</h2>";
}

テーブルの行を更新する必要がありますが、そうではありません。入力値は正常に送信されています。解決策を教えてください..

コードのどの部分が間違っていますか?????

4

1 に答える 1