我創建了添加評論腳本。爲什麼腳本無法正常工作?
來源 -
if (isset($_GET['do']) and $_GET['do'] == 'comment'){//Ja viss kārtībā, turpinam
if (!empty($_POST['name']) and !empty($_POST['artcl_id']) and !empty($_POST['homepage']) and !empty($_POST['text'])){
$name = trim($_POST['name'],' ');
$artcl_id = trim($_POST['artcl_id'],' ');
$homepage = trim($_POST['homepage'],' ');
$text = trim($_POST['text'],' ');
Model::factory('index')
->send_commentar(mysql_real_escape_string($name), mysql_real_escape_string($artcl_id), mysql_escape_string($homepage), mysql_real_escape_string($text), mysql_real_escape_string(time()));
?>
<script type="text/javascript">
alert("Thank you! :)");
</script>
<meta http-equiv="REFRESH" content="0;url=/article/<?php echo $slug; ?>"/>
<?php
} else {
$this->template->content = View::factory('index/error')->set('message', 'How to submit empty comment?');
}
}
但如果我把空格中輸入字段,腳本發送空格。爲什麼腳本無法正常工作?如果你想刪除整個字符串中的空白,那麼你可以使用str_replace()函數功能
「他們開始工作」是一個不正確的陳述以及 –