Проблема метода PHP POST, загрузка рецепта - PullRequest
0 голосов
/ 27 февраля 2019

интерфейс загрузки рецептов Это мой код для загрузки рецептов (new.php), после нажатия кнопки отправки он будет загружен в mysql.Я попытался проверить, не устарели ли какие-либо коды mysql, изменив их на mysqli.Потому что этот проект немного староват.Так что на других страницах я изменил многие mysql на mysqli.

<form method="post" action="new.php" enctype="multipart/form-data" class="form3">


***I'm suspecting that the mistake is from here. As all the other parts of the code seem to be okay to me.***


    if (isset($_POST['submit'])){

     $title = $_POST['title'];
     $date = date('Y.m.d');
     $author = $_POST['author'];
     $desc = $_POST['desc'];
     $image_name = $_FILES ['image'] ['name'];
     $image_type = $_FILES ['image']['type'];
     $image_size = $_FILES ['image']['size'];
     $image_tmp = $_FILES  ['image']['tmp_name'];

    if($title =='' or $author =='' or $desc ==''){
        echo"<script>alert('Some Field/fields is/are Empty')</script>";
        exit();
    }
    if($image_type=="image/jpeg" or $image_type=="image/png" or   $image_type=="image/gif"){

        if($image_size<=50000){
            move_uploaded_file($image_tmp,"uploads/$image_name");
        }
        else{
            echo"<script>alert('Image is Larger, Only 50kb size is   allowed')</script>";
        }
    }
    else{
        echo"<script>alert('Image Type is Invalid')</script>";
    }
    $query = "insert into    new_recipe(post_title,post_date,post_author,post_image,post_desc
    ) values('$title','$date','$author','$image_name','
    $desc')";

    if (mysqli_query($con,$query)){
        echo "<center><h1>Recipe Has Been Submitted!</h1></center>";
    }
}
 **Once all the details have been typed. When I click on submit , it doesn't give me any error/s. There were some previous recipes uploaded before I face these errors, and I can see them perfectly under the view.php page.**
?>
<?php } ?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...