<?
include("header.php");
include ("config.php");
?>
<?
if(isset($_SESSION['nume'])) {
      	$username = ''.$_SESSION['nume'].'';
$stare = "Post Message";
if(!$act){mysql_query("UPDATE utilizatori SET stare='$stare' WHERE nume='$username'");}
}
?>
<?

if(isset($_SESSION['nume'])) {
      	$userb = ''.$_SESSION['nume'].'';
 $getuser="SELECT * from utilizatori WHERE nume='$userb'";
  $getuser2=mysql_query($getuser) or die("COuld not draw cookies");
  $getuser3=mysql_fetch_array($getuser2);
  if(strlen($getuser3[nume])>1)
  {
    $_SESSION['user']=$getuser3[nume];        
if($getuser3[status]>=0)
    {
$file=$_GET['file'];
$ac=$_GET['ac'];
if($ac=="added")
{
if(empty($_POST["uname"]))
{
print "Please complete the name!<br/>";
}
elseif($_POST["uname"] > $username && $_POST["uname"] < $username)
{
print "Please use your name!<br/>";
}
elseif(empty($_POST["mail"]))
{
print "Please complete the email!<br/>";
}
elseif(empty($_POST["comment"]))
{
print "Please complete the comment!<br/>";
}
else{

$comment = htmlspecialchars($_POST["comment"], ENT_QUOTES);

 $insert = mysql_query("INSERT INTO comments SET uname='$userb', file='{$_GET['id']}', date='".time()."', comment='$comment', mail='".$_POST['mail']."'");
   if($insert){ 
print "Comentariu adaugat. Inapoi la <a href=\"file.php?id=".$_GET["id"]."\">Informatii fisier</a>.";
}
else{
print "Sorry,error.";}
}
}
echo "<br/><br/>";

}}}
?>
<?
include ("flooter.php");
?>