the interface of uploading recipe这是我的代码,用于上传配方(new.php),一旦单击“提交”按钮,它将被上传至mysql。我试图通过将它们更改为mysqli来检查是否有任何mysql代码已过时。因为这个项目有点旧。因此,在其他页面上,我将许多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 } ?>