<?php session_start();?>
<?php
include ('dbf.php');
if($_POST[ins])
{
   $valu=split(",",$_POST[ins]);
   $suq=mysql_query("insert into  majale_et (ip_majale,page_number,onvan,writer,user,city)
	VALUES ('{$valu[3]}','{$valu[0]}','{$valu[1]}','{$valu[2]}','{$_SESSION['user']}','{$_SESSION['city']}')");
   $row=mysql_query("select * from `majale_et` where ip_majale='{$valu[3]}'");
   $cd=mysql_num_rows($row);
   mysql_query("update majale set magh_number='{$cd}' where id='{$valu[3]}' ");
   if($suq)
      echo 'success';
   //$_SESSION[selpage]="majale_et.php";
   //include ('login.php');
}
elseif(isset($_POST['del']))
{

    $row1=mysql_query("select * from `majale_et` where ip='{$_POST['id']}'");
    $r=mysql_fetch_array($row1);
    $row=mysql_query("select * from `majale_et` where ip_majale='{$r['ip_majale']}'");
	$cd=mysql_num_rows($row);
    $cd-=1;
    mysql_query("update majale set magh_number='{$cd}' where id='{$r['ip_majale']}' ");
	mysql_query("delete from majale_et where ip={$_POST['id']}");

}
elseif (isset($_POST['edit']))
{
   $valu=split(",",$_POST['edit']);
   mysql_query("update majale_et set page_number='{$valu[0]}',onvan='{$valu[1]}'
	,writer='{$valu[2]}' where ip={$_POST['id']}");
   //$_SESSION[etm]='1';
   $_SESSION[selpage]="majale_et.php";
   include ('login.php');
}



?>