session_start(); include "admin/connect.php"; if (!isset($_GET['aid'])) { $q="SELECT * FROM `articles` ORDER BY `aid` DESC LIMIT 1"; $result=mysql_query($q); if ($r=mysql_fetch_assoc($result)) { $aid=$r['aid']; } else { $aid=0; } } else { $aid=$_GET['aid']; } if ($_GET['action']=='add_comm') { if (($_POST['name']!='') and ($_POST['comment']!='') and ($_POST['captcha']==$_SESSION['security_code'])) { $q="INSERT INTO `comments` (`aid`, `name`, `email`, `comment`, `date`) VALUES ('".$aid."', '".strip_tags($_POST['name'])."', '".strip_tags($_POST['email'])."', '".strip_tags($_POST['comment'])."', '".time()."')"; mysql_query($q) or die (mysql_error()); header('Location: articole.php?aid='.$aid); } } ?>