<?php session_start();?>
<?php
include ('dbf.php');
if($_POST[ins])
{
   $valu=split(",",$_POST[ins]);
   $row=mysql_query("select * from `cd` where ip='{$valu[0]}'");
   $cd=mysql_num_rows($row);
   if($cd=='0')
  	 $suq=mysql_query("insert into `cd` (`ip` ,`topic` ,`contents` ,`number` ,`s_emtiaz` , `price` ,`tou` ,`user`,`city`)
	VALUES ('{$valu[0]}','{$valu[1]}','{$valu[2]}','{$valu[5]}'
	,'{$valu[3]}','{$valu[4]}','{$valu[6]}','{$_SESSION['user']}','{$_SESSION['city']}')");
    if($suq)
      echo 'success';
    else
	 echo'<span class="blacktext">شماره سي دي تكراري است</span>';
}
if (isset($_POST['del']))
{
	mysql_query("delete from cd where id={$_POST['id']}");
}
if (isset($_POST['edit']))
{
    $valu=split(",",$_POST['edit']);
	$r=mysql_query("update `cd` set `ip`='{$valu[0]}',`topic`='{$valu[1]}'
	,`contents`='{$valu[2]}',`number`='{$valu[5]}',`s_emtiaz`='{$valu[3]}'
	,`price`='{$valu[4]}',`tou`='{$valu[6]}',`city`='{$_SESSION['city']}'
	 where `id`={$_POST['id']}");
	 $_SESSION[selpage]="cd.php";
     include ('login.php');
}

?>