I created the add comment script.
Source –
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?');
}
}
But if I am putting white spaces in input field, the script send white spaces. Why the script don’t work correctly?
You’re removing whitespaces after you checked on empty fields. Don’t you want that turned around? First remove whitespaces and then checking for empty fields?