<?php

session_start();

ob_start();

include_once("../dbconnect.php");

$action = isset($_GET['action']) ? $_GET['action'] : '';

 switch ($action) {


    case 'add' :

        add();

        break;

    case 'delete' :

        delete();

        break;	

		

	    case 'edit' :

	     edit();

         break;

		    case 'status' :

	     status();

         break;

		 

default :

        // if action is not defined or unknown

        // move to main category page

        header('Location: welcomepage.php');

		

}

function add()

{
 
	mysql_query("insert into states(country_id, state_name, status) values('".$_POST['cntid']."','".$_POST['state_name']."',1)");

header("location:addstate.php?cntid=".$_POST['cntid']);

}

function delete()

{

	mysql_query("delete from states where state_id=".$_GET['state_id']);

	header("location:addstate.php?cntid=".$_GET['cntid']);

}

 

function status()

{

	mysql_query("update states set mec_status='".$_GET['mec_status']."' where mec_p_id=".$_GET['mec_p_id']);

	header("location:addstate.php");

}

?>