<?php
error_reporting(0);
@session_start();
include("config.php");
$post_name=$_POST['post_name'];

$flag = $_REQUEST[flag];


/***********************************/
$id= $_POST[id];
if($flag=="del")
{
	$id= $_GET[id];	
	
	
	$query=sprintf("Delete from post where id ='%d'", $id);
 $conn->query($query);
	header("Location:add_post.php?flag=del");
	exit;
}
if($id=="")
{ 
    	
		 $qadd4=sprintf("INSERT INTO post set post_name='$post_name'");
		   $conn->query($qadd4);
		  
		 header("Location:add_post.php?flag=dn");
		 exit;
}
$id= $_POST[id];
if($id!="")
{
          $query_up=sprintf("UPDATE post SET  post_name='$post_name' WHERE id='%d' ",$id); 
		  $conn->query($query_up);
   
	
		header("Location:add_post.php?flag=up");
		exit;
		
		}
?>
