我正在尝试在表单的注释框中提交很长的消息(例如,超过2000个字母)。但收到“评论尚未提交”。请检查以下代码:
我已将数据库内的注释类型更改为TEXT以及MEDIUMTEXT和LONGTEXT,但没有任何效果。它仍然显示“评论尚未提交”。
<?php
if(isset($_POST['submit']))
{
$cs_name = $_POST['name'];
$cs_email = $_POST['email'];
$cs_comment = $_POST['comment'];
$cs_image = implode(',', $_FILES['image']['name']);
$cs_images = $_FILES['image']['name'];
$cs_image_tmp = $_FILES['image']['tmp_name'];
$cs_image_type = $_FILES['image']['type'];
$cs_rating = $_POST['rating'];
$cs_date = time();
if(empty($cs_name) or empty($cs_email) or empty($cs_comment))
{
$error_msg = "All (*) feilds are compulsary";
}
else
{
$cs_query = "INSERT INTO `comments` (`id`, `date`, `name`,
`username`, `comp_id`, `email`, `image`, `comment`,
`rating`,`status`, `type`) VALUES (NULL, '$cs_date', '$cs_name',
'user', '$comp_id', '$cs_email',
'$cs_image', '$cs_comment', '$cs_rating', 'pending', 'C')";
if(mysqli_query($con, $cs_query))
{
$msg = "Comment Submitted and waiting for Approval";
for($i=0; $i<=count($cs_image_tmp)-1;$i++)
{
move_uploaded_file($cs_image_tmp[$i],
"admin/images/uploded/$cs_images[$i]");
}
header('Location: companies.php?comp_id='.$comp_id.'');
exit();
}
else
{
$error_msg = "Comment has not be submitted";
}
}
}
?>
它应该提交一个很长的评论(例如成功地发送2000多个字母并将其存储在数据库中。
答案 0 :(得分:0)
是的,我得到了答案。我在for_move_uploded_files循环之前添加了一个if条件。那在制造问题。
if(!empty($cs_images)){
for($i=0; $i<=count($cs_image_tmp)-1;$i++){
move_uploaded_file($cs_image_tmp[$i], "admin/images/uploded/$cs_images[$i]");
}
}
非常感谢您的评论。