Ahojte.. v stranke (dajme tomu, ze niekde v strede) mam umiestneny formular na pridavanie komentarov.. po odoslani sa dokazem na tento formular nastavit (aby sa stranka rovno posunula nanho) pomocou odkazu index.php....#add_comment. Ale v pripade ze uziatel zada zle data tak ho to presunie uplne na zaciatok stranky a potom musi scrollovat zase dole.. no a ja by som chcel aby ho to tam premiestnilo rovno (aj pri vyplnenom formulari). Nevedel som kam tento prispevok zaradit, tak som ho supol do tejto sekcie.. Kod nie je este celkom upraveny takze ho berte z rezervou
$ip = $_SERVER["REMOTE_ADDR"];
$check_user_comment = mysql_query("
SELECT *
FROM table
WHERE ip = '$ip'
AND id_item = '$id_item'
AND datum_pridania
BETWEEN DATE_SUB( now( ) , INTERVAL '15'MINUTE )
AND now( )
");
$check_user = mysql_fetch_array($check_user_comment);
if(!$check_user){
$view = "no";
$result = "";
if($send == "yes"){
if($meno == ""){
$view = "yes";
$result .= '<span class="shadow fail">Prosím, zadajte vaše meno</span>';
}
elseif($meno == "Milan Kohút" || $meno == "MilanKohút" || $meno == "Milan Kohut" || $meno == "MilanKohut" ){
$view = "yes";
$result .= '<span class="shadow fail">Zadali ste zlé meno</span>';
}
if($email == ""){
$view = "yes";
$result .= '<span class="shadow fail">Prosím, zadajte váš email</span>';
}
if($komentar == ""){
$view = "yes";
$result .= '<span class="shadow fail">Prosím, zadajte váš komentár</span>';
}
}
else{
$view = "yes";
}
if($view == "yes"){
?>
<div class="comment" id="add_comment">
<h2 class="h2-blogitem">Pridaj komentár</h2>
<?php if(isset($result)){ echo $result; } ?>
<form method="post" enctype="multipart/form-data">
<label for="meno">Meno <span class="orange">(Povinné)</span></label>
<input type="text" class="comment-input" name="meno"/>
<label for="email">E-mail <span class="orange">(Povinné)</span></label>
<input type="text" class="comment-input" name="email"/>
<label for="web">Web</label>
<input type="text" class="comment-input" name="web"/>
<label for="komentar">Komentár <span class="orange">(Povinné)</span></label>
<textarea name="komentar"></textarea>
<input type="submit" value="" class="comm-submit" />
<input type="hidden" name="send" value="yes"/>
</form>
</div>
<?php
}
else{
$komentar = WordWrap($komentar, 200, " ", 1);
$komentar = Str_Replace("<","<",$komentar);
$komentar = Str_Replace(">",">",$komentar);
$ip = $_SERVER["REMOTE_ADDR"];
mysql_query("INSERT INTO table (id_item,meno,email,web,komentar,ip,datum_pridania) VALUES('$id_item','$meno','$email','$web','$komentar','$ip', now())");
echo '
<div class="comment" id="add_comment">
<h2 class="h2-blankcomment">Komentár bol úspešne odoslaný</h2>
<span class="shadow">Ďakujem vám za váš komentár k tomuto príspevku</span>
</div>';
?>
<meta http-equiv="refresh" content="0;URL=index.php?page=blog_read&id_item=<?php echo $id_item; ?>#add_comment"/>
<?php
}
}
else{
echo '
<div class="comment" id="add_comment">
<h2 class="h2-blankcomment">Pridávanie komentárov</h2>
<span class="shadow">K tomuto príspevku môžete pridávať komentáre len v 15 minútovom intervale</span>
</div>';
}
dakujem za radu ;)