0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: stockentry_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; require_once"../model/employee_mdl.php"; $u_id= @$_SESSION['user_id']; $sql="select * from stockitem where user_id='$u_id'"; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $item_name_db=$row['item_name']; $item_desc_db[$i]=$row['description']; $i=$i+1; $item_name_array[$i]=$item_name_db; } $item_name_restore=@$_POST['cmbitem']; $item_name=$item_name_array[$item_name_restore]; if(isset($_POST['savebtn'])) { $error_flag=0; $stockdate_dd=@$_POST['cmbitemdd']; $stockdate_mm=@$_POST['cmbitemmm']; $stockdate_yy=@$_POST['txtitemyy']; $itemsinstock=@$_POST['txtnoitems']; $stockitemdescription=@$_POST['txtitemdesc']; $stockdescription=@$_POST['txtstockdesc']; $stockdate=$stockdate_yy."-".$stockdate_mm."-".$stockdate_dd; if (!is_numeric(@$_POST['txtitemyy'])) { $error['year_numeric']="Only allow numbers"; $error_flag=1; } if (!is_numeric(@$_POST['txtnoitems'])) { $error['itemnumber_numeric']="Only allow numbers"; $error_flag=1; } if($itemsinstock=="") { $error['name_null']="Please Enter number of items in stock"; $error_flag=1; } if($stockdate_yy=="") { $error['year_null']="Please Enter year"; $error_flag=1; } //if($stockdescription=="") // { // $error['description_null']="Please Enter description"; // $error_flag=1; // } //if($stockitemdescription=="") // { // $error['itemdescription_null']="Please Enter description"; // $error_flag=1; // } if($error_flag==1) { /*echo "<script>window.location='http://localhost/CPFMS/USER/stockentry.php</script>";*/ include("stockentry.php"); exit(); } else { $table_id=Common::getTableID("stockentry","stockentry_id"); $table_id=$table_id+1; $u_id=@$_SESSION['user_id']; //$p_id=@$_SESSION['project_id']; $sql="INSERT INTO `stockentry`( `stockentry_id`, `user_id`, `item_name`, `stockentrydate`, `itemsinstock`, `description` ) VALUES ( '$table_id','$u_id','$item_name','$stockdate','$itemsinstock','$stockdescription' ) "; mysql_query($sql); if (mysql_affected_rows()>0) { $message="Registration Completed successfully.."; include("stockentry.php"); exit(); } else { $message= "Registration Failed.Invalid charactors found"; include("stockentry.php"); exit(); } } } ?>