ok
Direktori : /home2/selectio/www/pvmatricschool.com/admin/api/ |
Current File : /home2/selectio/www/pvmatricschool.com/admin/api/create-wishes-api.php |
<?php session_start(); include"../config/config.php"; if(isset($_POST['type']) && $_POST['type']=='add_wishes'){ try{ $date = date('Y-m-d h:i:s', time()); if(isset($_FILES['photo']) && $_FILES["photo"]["name"]!=""){ $extension = end(explode(".", $_FILES["photo"]["name"])); $image = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['photo']['tmp_name'], '../upload/' . $image); $upload_image = 'upload/' . $image; } else{ $upload_image=''; } $statement = $pdo->prepare("INSERT INTO `tbl_wishes`(`photo`, `employee_id`, `employee_name`, `designation`,type,department_id,status,wishes_type,date) VALUES (?,?,?,?,?,?,?,?,?)"); $result=$statement->execute(array($upload_image,$_POST['employee_code'],$_POST['employee_name'],$_POST['designation'],$_POST['wishes_type'],$_POST['department_id'],$_POST['wishes_status'],$_POST['type_wishes'],$_POST['wishes_date'])); if($result){ $return_arr['message'] = 'Wishes Added successfully!'; $return_arr['status']=200; }else{ $return_arr['message']="Something went wrong try again..."; $return_arr['status']=400; } }catch(Exception $e){ $return_arr['message']='0987'.$e; $return_arr['status']=500; } echo json_encode($return_arr); } ?>