<?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 cities(state_id, city_name, status) values('".$_POST['stid']."','".$_POST['city_name']."',1)");

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

}

function delete()

{

	mysql_query("delete from cities where city_id=".$_GET['city_id']);

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

}

 

function status()

{

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

	header("location:addcity.php");

}

?>