ok
Direktori : /proc/self/root/home2/selectio/www/wedding-info-new/api/ |
Current File : //proc/self/root/home2/selectio/www/wedding-info-new/api/astrologer_add.php |
<?php include_once('config/config.php'); session_start(); error_log('formstarts rest........'); $return_arr = array(); // Initialize the return array if (isset($_POST['type']) && $_POST['type'] == 'upload') { if ($_POST['edit'] == 'edit') { $statement = $pdo->prepare("SELECT * FROM `tbl_astrologer` WHERE `id` = ?"); $statement->execute([$_SESSION['user']['id']]); $match = $statement->fetch(PDO::FETCH_ASSOC); error_log($annual_incm_limit."get incm". $match['annual_incm_limit']."db"); error_log($match['annual_incm_limit'] . " db"); error_log($match['annual_incm'] . " db"); error_log($annual_incm_limit . " post"); error_log($annual_income . " post"); if($annual_income == $match['annual_incm']){ error_log('success'); } $annual_incm_limit = ($annual_income == $match['annual_incm']) ? $annual_incm_limit : ($annual_incm_limit - 1); $marital_status_limit = ($marital_status == $match['martial_status']) ? $marital_status_limit : ($marital_status_limit - 1); $wa_limit = ($alter_mobile_no == $match['mobile_no_alt']) ? $wa_limit : ($wa_limit - 1); $occupation_limit = ($occupation == $match['occupation']) ? $occupation_limit : ($occupation_limit - 1); $phy_limit = ($physical_status == $match['phy_status']) ? $phy_limit : ($phy_limit - 1); $intrest_limit = ($intrests == $match['intrests']) ? $intrest_limit : ($intrest_limit - 1); } $occupation = $_POST['occupation']; $alter_mobile_no = $_POST['alter_mobile_no']; $id = $_SESSION['astrologer']['id']; $profile_created_for = $_POST['profile_created_for']; $profile_name = $_POST['profile_name']; $gender = $_POST['gender']; $dob = $_POST['dob']; $age = $_POST['age']; // $country = $_POST['country']; $mobile_no = $_POST['mobile_no']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $pin_code = $_POST['pin_code']; $land_mark = $_POST['land_mark']; $email_id = $_POST['email_id']; $occupation = $_POST['occupation']; $education = $_POST['education']; $experience = $_POST['experience']; $language = $_POST['language']; // marital_status_limit annual_incm_limit // Prepare and execute the SQL statement $statement = $pdo->prepare("UPDATE `tbl_astrologer` SET `profile_created_for` = ?, `name` = ?, `gender` = ?, `dob` = ?, `age` = ?, `astrologer_mobile` = ?, `astrologer_mobile_alt` = ?, `astrologer_email` = ?, `address` = ?, `city` = ?, `state` = ?, `pincode` = ?, `landmark` = ?, `occupation` = ?, `education` = ?, `experience` = ?, `language` = ? WHERE `id` = ?"); $result = $statement->execute([ $profile_created_for, $profile_name, $gender, $dob, $age, $mobile_no, $alter_mobile_no, $email_id, $address, $city, $state, $pin_code, $land_mark, $occupation, $education, $experience, $language, $id // Assuming $id contains the ID of the record you want to update ]); $_SESSION['astrologer']['personal_info_cmt'] = 1; if ($result) { $return_arr['message'] = 'Astrologer Updated successfully.'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Something went wrong.'; $return_arr['status'] = 400; } echo json_encode($return_arr); } if (isset($_POST['type']) && $_POST['type'] == 'plan_form') { error_log('formstarts plan rest........'); $id = $_SESSION['astrologer']['id']; $plan_hrs = $_POST['plan_hrs']; $plan_mins = $_POST['plan_mins']; $plan_profiles = $_POST['plan_profiles']; // marital_status_limit annual_incm_limit // Prepare and execute the SQL statement $statement = $pdo->prepare("UPDATE `tbl_astrologer` SET `plan_hrs` = ?, `plan_mins` = ?, `plan_profile` = ? WHERE `id` = ?"); $result = $statement->execute([ $plan_hrs, $plan_mins, $plan_profiles, $id // Assuming $id contains the ID of the record you want to update ]); $_SESSION['astrologer']['personal_info_cmt'] = 1; if ($result) { $return_arr['message'] = 'Astrologer Updated successfully.'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Something went wrong.'; $return_arr['status'] = 400; } echo json_encode($return_arr); } if (isset($_POST['type']) && $_POST['type'] == 'verification') { try { // Validation and sanitization of input fields here function generateUniqueFileName($originalName) { $extension = pathinfo($originalName, PATHINFO_EXTENSION); $image = rand(10, 1000000000) . "-" . date('Y-m-d_his') . "-images." . $extension; return $image; } $fileFields = ['proof_zero', 'proof_first', 'proof_two', 'proof_three']; $fileNames = []; foreach ($fileFields as $fieldName) { if (isset($_FILES[$fieldName]) && $_FILES[$fieldName]["name"] != "") { $fileName = './uploads/proof/' . generateUniqueFileName($_FILES[$fieldName]['name']); $targetPath = "." . $fileName; if (move_uploaded_file($_FILES[$fieldName]['tmp_name'], $targetPath)) { $fileNames[$fieldName] = $fileName; } else { throw new Exception('Failed to move uploaded file.'); } } else { $fileNames[$fieldName] = $_POST['oldfileInput_' . $fieldName]; } } $ids = $_SESSION['astrologer']['id']; $dhosam = $_POST['dhosam']; $verified_aadhar_no = $_POST['verified_aadhar_no']; $verified_aadhar_mobile_no = $_POST['verified_aadhar_mobile_no']; $birth_certificatenumber = $_POST['birth_certificatenumber']; $communication_certificate = $_POST['communication_certificate']; $agreement = $_POST['agreement']; $verified_aadhar_name = $_POST['verified_aadhar_name']; // Your validation and sanitization code goes here // Prepare the SQL query (removed extra comma, added placeholder for verification_info_cmt) $statement = $pdo->prepare("UPDATE `tbl_astrologer` SET `v_photos` = ?, `v_birthcert` = ?, `v_aadhar_name` = ?, `name` = ?, `v_aadhar` = ?, `v_aadhar_no` = ?, `v_aadhar_mobile` = ?, `astrologer_mobile` = ?, `v_birth_cert_no` = ?, `h_communication` = ?, `h_communication_no` = ? WHERE `id` = ? "); // Execute the query with appropriate parameters $result = $statement->execute([ $fileNames['proof_first'], $fileNames['proof_two'], $verified_aadhar_name, $verified_aadhar_name, $fileNames['proof_zero'], $verified_aadhar_no, $verified_aadhar_mobile_no, $verified_aadhar_mobile_no, $birth_certificatenumber, $fileNames['proof_three'], $communication_certificate, $ids ]); if ($result) { // Update session variable only if the update operation is successful $_SESSION['user']['verification_info_cmt'] = 1; $return_arr['message'] = 'Details Updated successfully.'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Something went wrong.'; $return_arr['status'] = 400; } } catch (Exception $e) { $return_arr['message'] = 'Internal Server Error: ' . $e->getMessage(); $return_arr['status'] = 500; error_log($e->getMessage()); } echo json_encode($return_arr); } ?>