<?php
error_reporting(0);
include("../../include/Class.php");
 $unit = new Unit();

function check_item($user_name)
{
$Isql=mysql_query("select * from user_creation where user_name='$user_name'");
$rscount=mysql_num_rows($Isql);
return $rscount;
}
 
/********************************** ADD & UPDATE QUERY ***************************************/
if($_POST['action']=='ADD')
{
$user_name=$_POST['user_name'];
$password=$_POST['password'];
$confirm_password=$_POST['confirm_password'];
$status=$_POST['status'];
$check_item=check_item($_POST['user_name']);
if($check_item==0)
{
$Insql=mysql_query("insert into user_creation(user_name,password,status,confirm_password)values('$user_name','$password','$status','$confirm_password')");
echo  "<script>alert('Successfully Added ')</script>";
}
}
/*********************************** UPDATE QUERY *********************************************/
if($_POST[action]=='EDIT')
{
$edit_id=$_POST['edit_id'];
$user_name=$_POST['user_name'];
$password=$_POST['password'];
$confirm_password=$_POST['confirm_password'];
$status=$_POST['status'];
$Insql=mysql_query("update user_creation SET user_name='$user_name',password='$password',status='$status',confirm_password='$confirm_password' where user_id='$_POST[edit_id]'");
echo "<script>alert('Edited Successfully')</script>";
}
/**********************************************************************************************/
if($_POST[action]== 'del_user')
{
$Insql=mysql_query("delete from user_creation where user_id='$_POST[user_id]'");
echo "<script>alert('Deleted Successfully')</script>";

}
include("user_creation_list.php");
?>
