我正在编辑CMS的页面。我正在检查是否有任何输入是空的(因为这是一个编辑页面,我回显了值,所以不会有任何空字段,它甚至不应该输入if循环)即使它进入它应该显示一些错误但它没有。
if(isset($_POST['update'])){
$update_id = $_GET['edit_form'];
$post_title1=$_POST['title'];
$post_keywords1=$_POST['keywords'];
$post_content1=$_POST['content'];
$post_category1=$_POST['category'];
$post_image1=$_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
echo $post_content1 ;
if($post_title1 == '' or $post_keywords1 == '' or $post_content1 == '' or $post_category1 == '' or $post_image1 == '') {
echo " <script>some value is empty plz check </script>" ;
exit();
}
else {
echo $post_content1 ;
move_uploaded_file($image_tmp,"../final/images/$post_image1");
$update_query = "update articles set article_title='$post_title1' , article_content='$post_content1', article_image='$post_image1', category='$post_category1', article_keywords='$post_keywords1' WHERE article_id='$post_id'";
if(mysqli_query($conn,$update_query)== 1 ) {
echo "<script> alert('article updated')</script> " ;
}
else {
echo "failed".mysqli_error($conn);
}
}
}
答案 0 :(得分:1)
echo " <script>some value is empty plz check </script>" ;
这只包含脚本标记中的文本,该标记将不执行任何操作。您在其他陈述中需要alert
此错误。
echo " <script>alert('a required value is empty please check your input'); </script>" ;