0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: additem_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; //include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); require_once "../model/defaultValues_mdl.php"; $u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select * from stockcategory where user_id='$u_id' "; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $stock_acc=$row['category_name']; $i=$i+1; $stock_acc_array[$i]=$stock_acc; } $error_flag=0; $itemname_restore=@$_POST['txtitemname']; $stock_acc_restore=@$_POST['cmbstockacc']; $description=@$_POST['txtdescription']; $acc_name=$stock_acc_array[$stock_acc_restore]; if(isset($_POST['add'])) {//28 //---------Null--------// if($itemname_restore=="") { $error['itemname_restore_null']="Please Enter Itemname"; $error_flag=1; } //if($description=="") // { // $error['description_null']="Please Enter Description"; // $error_flag=1; // } $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="select * from stockitem where user_id='$u_id' and category_name='$acc_name' and item_name='$itemname_restore'"; mysql_query($sql); if (mysql_affected_rows()>0) { $error['itemname_exist']="Itemname exist"; $error_flag=1; } if($error_flag==1) { include("additem.php"); exit(); } else { $table_id=Common::getTableID("stockitem","item_id"); $table_id=$table_id+1; $u_id=@$_SESSION['user_id']; $p_id=@$_SESSION['project_id']; $sql="INSERT INTO `stockitem`( `item_id`, `user_id`, `item_name`, `category_name`, `description` ) VALUES ( '$table_id','$u_id','$itemname_restore','$acc_name','$description' ) "; mysql_query($sql); if (mysql_affected_rows()>0) { $message="Registration Completed successfully.."; include("additem.php"); exit(); } else { $message= "Registration Failed.Invalid charactors found"; include("additem.php"); exit(); } } }//28 ?>