/home/u775757334/domains/civicwelllife.com/public_html/function
Edit: /home/u775757334/domains/civicwelllife.com/public_html/function/ajax_function.php (154963B)
0) {
$row = mysqli_fetch_array($sql);
extract($row);
if (strtolower($email) == strtolower($cemail) && $s_password == $spassword) {
$customerID = $row['id'];
$_SESSION['reffral_id'] = $row['id'];
$_SESSION['reffral_name'] = $row['name'];
$_SESSION['reffral_email'] = $row['email'];
$_SESSION['reffral_phone'] = $row['phone'];
echo '1';
} else {
echo "you have enter wrong email id and password";
}
} else {
echo "you have enter wrong email id and password";
}
}
function addReffral($conn)
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = $_POST['password'];
$location = $_POST['location'];
$code = generateUniqueCode(8);
$sql = mysqli_query($conn, "select * from tbl_reffral_user where email='$email' or code='$code'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
echo "You have Already Registred";
} else {
$sql = "insert into tbl_reffral_user(name,email,phone,s_password,location,code) values('$name','$email','$phone','$password','$location','$code')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for Applying";
} else {
echo "Please try again.";
}
}
}
function savetestimonial($conn)
{
$doctor_id = isset($_POST['doctor_id']) ? (int)$_POST['doctor_id'] : 0;
$name = mysqli_real_escape_string($conn, trim($_POST['name'] ?? ''));
$rating = isset($_POST['rating']) ? (int)$_POST['rating'] : 0;
$description = mysqli_real_escape_string($conn, trim($_POST['description'] ?? ''));
if ($doctor_id <= 0) {
echo json_encode(['status' => 0, 'msg' => 'Doctor ID missing']);
exit;
}
if ($name === '') {
echo json_encode(['status' => 0, 'msg' => 'Name is required']);
exit;
}
if ($rating <= 0 || $rating > 5) {
echo json_encode(['status' => 0, 'msg' => 'Please select rating']);
exit;
}
if ($description === '') {
echo json_encode(['status' => 0, 'msg' => 'Please write your feedback']);
exit;
}
$sql = "INSERT INTO tbl_testimonial (doctor_id, name, rating, description)
VALUES ('$doctor_id', '$name', '$rating', '$description')";
$run = mysqli_query($conn, $sql);
if ($run) {
echo json_encode([
'status' => 1,
'msg' => 'Review submitted successfully',
'redirect' => 'index.php'
]);
} else {
echo json_encode([
'status' => 0,
'msg' => 'DB Error: ' . mysqli_error($conn)
]);
}
exit;
}
function saveTiming($conn)
{
// session_start();
if (!isset($_SESSION['doctor_id'])) {
echo json_encode(['status' => 0, 'msg' => 'Session expired']);
exit;
}
$doctor_id = $_SESSION['doctor_id'];
$id = $_POST['id'] ?? '';
$day = $_POST['day'];
$start = $_POST['start_timming'];
$end = $_POST['evening_time'];
if (empty($day) || empty($start) || empty($end)) {
echo json_encode(['status' => 0, 'msg' => 'All fields required']);
exit;
}
// 🔥 UPDATE
if ($id) {
$sql = "UPDATE tbl_timmng SET
day='$day',
start_timming='$start',
evening_time='$end'
WHERE id='$id'";
} else {
// 🔥 INSERT
$sql = "INSERT INTO tbl_timmng
(day,start_timming,evening_time,doctor_id)
VALUES
('$day','$start','$end','$doctor_id')";
}
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Saved Successfully']);
} else {
echo json_encode(['status' => 0, 'msg' => mysqli_error($conn)]);
}
exit;
}
function saveBlog($conn)
{
// session_start();
if (!isset($_SESSION['doctor_id'])) {
echo json_encode(['status' => 0, 'msg' => 'Session expired']);
exit;
}
$doctor_id = $_SESSION['doctor_id'];
$id = $_POST['id'] ?? '';
$title = mysqli_real_escape_string($conn, $_POST['title']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$short_description = mysqli_real_escape_string($conn, $_POST['short_description']);
$category_id = mysqli_real_escape_string($conn, $_POST['category_id']);
$slug = mysqli_real_escape_string($conn, $_POST['slug']);
// AUTO SLUG BACKUP
if (empty($slug)) {
$slug = strtolower(trim($title));
$slug = preg_replace('/[^a-z0-9-]+/', '-', $slug);
}
$image = '';
// IMAGE UPLOAD
if (!empty($_FILES['image']['name'])) {
$image = time() . "_" . $_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], "../media/image/" . $image);
}
if ($id) {
// UPDATE
if (!empty($image)) {
$sql = "UPDATE tbl_blog SET
heading='$title',
slug='$slug',
description='$description',
image1='$image',short_description = '$short_description',category_id = '$category_id'
WHERE id='$id'";
} else {
$sql = "UPDATE tbl_blog SET
heading='$title',
slug='$slug',
description='$description',short_description = '$short_description',category_id = '$category_id'
WHERE id='$id'";
}
} else {
// INSERT
$sql = "INSERT INTO tbl_blog
(doctor_id,heading,slug,description,image1,short_description,category_id)
VALUES
('$doctor_id','$title','$slug','$description','$image','$short_description','$category_id')";
}
// 🔥 EXECUTE + ERROR CHECK
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Saved Successfully']);
} else {
echo json_encode([
'status' => 0,
'msg' => 'DB Error: ' . mysqli_error($conn)
]);
}
exit;
}
function saveBooking($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['name']);
$age = mysqli_real_escape_string($conn, $_POST['age']);
$gender = mysqli_real_escape_string($conn, $_POST['gender']);
$city = mysqli_real_escape_string($conn, $_POST['city']);
$mobile = mysqli_real_escape_string($conn, $_POST['mobile']);
$consultation = mysqli_real_escape_string($conn, $_POST['consultation']);
$query = "INSERT INTO tbl_survey_enquiry
(name, age, gender, city, mobile, consultation_type)
VALUES
('$name', '$age', '$gender', '$city', '$mobile', '$consultation')";
if (mysqli_query($conn, $query)) {
$booking_id = mysqli_insert_id($conn);
echo json_encode([
'status' => 'success',
'booking_id' => $booking_id
]);
} else {
echo json_encode([
'status' => 'error'
]);
}
}
function scoreText($score)
{
if ($score >= 80) return 'Good';
if ($score >= 60) return 'Moderate';
return 'Needs Attention';
}
// function saveResult($conn)
// {
// $booking_id = (int)($_POST['booking_id'] ?? 0);
// $answersRaw = $_POST['answers'] ?? '';
// if ($booking_id <= 0 || $answersRaw == '') {
// echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
// exit;
// }
// $answers = json_decode($answersRaw, true);
// if (!is_array($answers) || empty($answers)) {
// echo json_encode(['status' => 'error', 'message' => 'Answers not found']);
// exit;
// }
// $answerValues = array_values($answers);
// $vata = 0;
// $pitta = 0;
// $kapha = 0;
// $balanced = 0;
// foreach ($answerValues as $ans) {
// if ($ans === 'A') $vata++;
// if ($ans === 'B') $pitta++;
// if ($ans === 'C') $kapha++;
// if ($ans === 'D') $balanced++;
// }
// $total = count($answerValues);
// $vata_score = round(($vata / $total) * 100, 2);
// $pitta_score = round(($pitta / $total) * 100, 2);
// $kapha_score = round(($kapha / $total) * 100, 2);
// $balanced_score = round(($balanced / $total) * 100, 2);
// $digestiveBalanced = 0;
// for ($i = 5; $i <= 9; $i++) {
// if (isset($answerValues[$i]) && $answerValues[$i] === 'D') $digestiveBalanced++;
// }
// $mentalBalanced = 0;
// for ($i = 10; $i <= 14; $i++) {
// if (isset($answerValues[$i]) && $answerValues[$i] === 'D') $mentalBalanced++;
// }
// $lifestyleBalanced = 0;
// for ($i = 15; $i <= 24; $i++) {
// if (isset($answerValues[$i]) && $answerValues[$i] === 'D') $lifestyleBalanced++;
// }
// $digestive_score = round(($digestiveBalanced / 5) * 100);
// $mental_score = round(($mentalBalanced / 5) * 100);
// $lifestyle_score = round(($lifestyleBalanced / 10) * 100);
// $overall_score = round(($balanced / $total) * 100);
// $doshas = [
// 'Vata' => $vata,
// 'Pitta' => $pitta,
// 'Kapha' => $kapha
// ];
// arsort($doshas);
// $keys = array_keys($doshas);
// $dominant = $keys[0] . '-' . $keys[1];
// $b = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM tbl_survey_enquiry WHERE id='$booking_id'"));
// if (!$b) {
// echo json_encode(['status' => 'error', 'message' => 'Patient record not found']);
// exit;
// }
// $patient_name = mysqli_real_escape_string($conn, $b['name'] ?? '');
// $age = mysqli_real_escape_string($conn, $b['age'] ?? '');
// $gender = mysqli_real_escape_string($conn, $b['gender'] ?? '');
// $city = mysqli_real_escape_string($conn, $b['city'] ?? '');
// $mobile = mysqli_real_escape_string($conn, $b['mobile'] ?? '');
// $consultation_type = mysqli_real_escape_string($conn, $b['consultation_type'] ?? '');
// $answers_json = mysqli_real_escape_string($conn, json_encode($answers));
// $dominant_db = mysqli_real_escape_string($conn, $dominant);
// mysqli_query($conn, "INSERT INTO tbl_health_test_result SET
// booking_id='$booking_id',
// patient_name='$patient_name',
// age='$age',
// gender='$gender',
// city='$city',
// mobile='$mobile',
// vata_score='$vata_score',
// pitta_score='$pitta_score',
// kapha_score='$kapha_score',
// balanced_score='$balanced_score',
// digestive_score='$digestive_score',
// mental_score='$mental_score',
// lifestyle_score='$lifestyle_score',
// overall_score='$overall_score',
// dominant_constitution='$dominant_db',
// consultation_type='$consultation_type',
// answers_json='$answers_json'
// ");
// $suggestions = [];
// if (strpos($dominant, 'Vata') !== false) {
// $suggestions[] = "Warm food aur fixed routine follow karein.";
// }
// if (strpos($dominant, 'Pitta') !== false) {
// $suggestions[] = "Cooling diet aur stress control pe focus karein.";
// }
// if (strpos($dominant, 'Kapha') !== false) {
// $suggestions[] = "Daily exercise aur light diet maintain karein.";
// }
// // Overall based suggestion
// if ($overall_score < 60) {
// $suggestions[] = "Sleep, hydration aur daily routine improve karein.";
// }
// if ($overall_score >= 80) {
// $suggestions[] = "Great! Aapka health balance kaafi acha hai 👍";
// }
// echo json_encode([
// 'status' => 'success',
// 'data' => [
// 'patient_name' => $b['name'] ?? '',
// 'age' => $b['age'] ?? '',
// 'gender' => $b['gender'] ?? '',
// 'city' => $b['city'] ?? '',
// 'mobile' => $b['mobile'] ?? '',
// 'dominant_constitution' => $dominant,
// 'digestive_score' => $digestive_score,
// 'mental_score' => $mental_score,
// 'lifestyle_score' => $lifestyle_score,
// 'overall_score' => $overall_score,
// 'digestive_text' => scoreText($digestive_score),
// 'mental_text' => scoreText($mental_score),
// 'lifestyle_text' => scoreText($lifestyle_score),
// 'overall_text' => scoreText($overall_score),
// 'suggestions' => $suggestions
// ]
// ]);
// exit;
// }
function saveResult($conn)
{
$booking_id = (int)($_POST['booking_id'] ?? 0);
$answersRaw = $_POST['answers'] ?? '';
if ($booking_id <= 0 || $answersRaw == '') {
echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
exit;
}
$answers = json_decode($answersRaw, true);
if (!is_array($answers) || empty($answers)) {
echo json_encode(['status' => 'error', 'message' => 'Answers not found']);
exit;
}
$answerValues = array_values($answers);
$vata = 0;
$pitta = 0;
$kapha = 0;
$balanced = 0;
foreach ($answerValues as $ans) {
if ($ans === 'A') $vata++;
if ($ans === 'B') $pitta++;
if ($ans === 'C') $kapha++;
if ($ans === 'D') $balanced++;
}
$total = count($answerValues);
if ($total <= 0) {
echo json_encode(['status' => 'error', 'message' => 'Invalid answer count']);
exit;
}
$vata_score = round(($vata / $total) * 100, 2);
$pitta_score = round(($pitta / $total) * 100, 2);
$kapha_score = round(($kapha / $total) * 100, 2);
$balanced_score = round(($balanced / $total) * 100, 2);
$digestiveBalanced = 0;
for ($i = 5; $i <= 9; $i++) {
if (isset($answerValues[$i]) && $answerValues[$i] === 'D') {
$digestiveBalanced++;
}
}
$mentalBalanced = 0;
for ($i = 10; $i <= 14; $i++) {
if (isset($answerValues[$i]) && $answerValues[$i] === 'D') {
$mentalBalanced++;
}
}
$lifestyleBalanced = 0;
for ($i = 15; $i <= 24; $i++) {
if (isset($answerValues[$i]) && $answerValues[$i] === 'D') {
$lifestyleBalanced++;
}
}
$digestive_score = round(($digestiveBalanced / 5) * 100);
$mental_score = round(($mentalBalanced / 5) * 100);
$lifestyle_score = round(($lifestyleBalanced / 10) * 100);
$overall_score = round(($balanced / $total) * 100);
// Dominant constitution logic
$doshas = [
'Vata' => $vata,
'Pitta' => $pitta,
'Kapha' => $kapha
];
arsort($doshas);
$keys = array_keys($doshas);
$primary_dosha = $keys[0] ?? 'Balanced';
$secondary_dosha = $keys[1] ?? '';
// Agar balanced sabse zyada hai aur baaki dosha 0 ya bahut kam hain
if ($balanced >= max($vata, $pitta, $kapha) && $balanced > 0) {
$primary_dosha = 'Balanced';
$secondary_dosha = $keys[0] ?? '';
$dominant = $secondary_dosha ? ('Balanced-' . $secondary_dosha) : 'Balanced';
} else {
$dominant = $primary_dosha . ($secondary_dosha ? '-' . $secondary_dosha : '');
}
$b = mysqli_fetch_assoc(mysqli_query($conn, "SELECT * FROM tbl_survey_enquiry WHERE id='$booking_id'"));
if (!$b) {
echo json_encode(['status' => 'error', 'message' => 'Patient record not found']);
exit;
}
$patient_name = mysqli_real_escape_string($conn, $b['name'] ?? '');
$age = mysqli_real_escape_string($conn, $b['age'] ?? '');
$gender = mysqli_real_escape_string($conn, $b['gender'] ?? '');
$city = mysqli_real_escape_string($conn, $b['city'] ?? '');
$mobile = mysqli_real_escape_string($conn, $b['mobile'] ?? '');
$consultation_type = mysqli_real_escape_string($conn, $b['consultation_type'] ?? '');
$answers_json = mysqli_real_escape_string($conn, json_encode($answers));
$dominant_db = mysqli_real_escape_string($conn, $dominant);
$insert = mysqli_query($conn, "INSERT INTO tbl_health_test_result SET
booking_id='$booking_id',
patient_name='$patient_name',
age='$age',
gender='$gender',
city='$city',
mobile='$mobile',
vata_score='$vata_score',
pitta_score='$pitta_score',
kapha_score='$kapha_score',
balanced_score='$balanced_score',
digestive_score='$digestive_score',
mental_score='$mental_score',
lifestyle_score='$lifestyle_score',
overall_score='$overall_score',
dominant_constitution='$dominant_db',
consultation_type='$consultation_type',
answers_json='$answers_json'
");
if (!$insert) {
echo json_encode([
'status' => 'error',
'message' => 'Failed to save test result'
]);
exit;
}
$suggestions = [];
if (strpos($dominant, 'Vata') !== false) {
$suggestions[] = "Warm food aur fixed routine follow karein.";
$suggestions[] = "Cold drinks aur irregular sleeping habits avoid karein.";
$suggestions[] = "Daily oil massage aur gentle yoga helpful rahega.";
}
if (strpos($dominant, 'Pitta') !== false) {
$suggestions[] = "Cooling diet aur stress control pe focus karein.";
$suggestions[] = "Spicy, fried aur over-heating foods kam karein.";
$suggestions[] = "Meditation, pranayama aur hydration maintain karein.";
}
if (strpos($dominant, 'Kapha') !== false) {
$suggestions[] = "Daily exercise aur light diet maintain karein.";
$suggestions[] = "Heavy, oily aur sugary foods ko limit karein.";
$suggestions[] = "Morning walk aur active lifestyle rakhein.";
}
if (strpos($dominant, 'Balanced') !== false) {
$suggestions[] = "Aapka constitution kaafi balanced lag raha hai, isko maintain karne ke liye disciplined lifestyle rakhein.";
$suggestions[] = "Regular sleep, hydration aur balanced meals continue rakhein.";
}
if ($digestive_score < 60) {
$suggestions[] = "Digestive health ke liye timely meals aur light dinner rakhein.";
} else {
$suggestions[] = "Digestive balance theek rakhne ke liye overeating avoid karein.";
}
if ($mental_score < 60) {
$suggestions[] = "Mental wellness ke liye stress management aur proper sleep follow karein.";
} else {
$suggestions[] = "Mental clarity maintain karne ke liye mindfulness aur routine breaks lete rahen.";
}
if ($lifestyle_score < 60) {
$suggestions[] = "Lifestyle balance ke liye hydration aur physical activity improve karein.";
} else {
$suggestions[] = "Aapka lifestyle pattern achha hai, ise consistently maintain rakhein.";
}
if ($overall_score < 60) {
$suggestions[] = "Sleep, hydration aur daily routine improve karein.";
$suggestions[] = "Personalized AYUSH consultation lena useful rahega.";
} elseif ($overall_score >= 60 && $overall_score < 80) {
$suggestions[] = "Aapka health balance moderate hai, thoda aur discipline se result better ho sakta hai.";
} else {
$suggestions[] = "Great! Aapka health balance kaafi acha hai 👍";
$suggestions[] = "Current routine ko continue rakhein aur regular wellness check karte rahen.";
}
$suggestions = array_values(array_unique($suggestions));
echo json_encode([
'status' => 'success',
'data' => [
'patient_name' => $b['name'] ?? '',
'age' => $b['age'] ?? '',
'gender' => $b['gender'] ?? '',
'city' => $b['city'] ?? '',
'mobile' => $b['mobile'] ?? '',
'dominant_constitution' => $dominant,
'primary_dosha' => $primary_dosha,
'secondary_dosha' => $secondary_dosha,
'vata_score' => $vata_score,
'pitta_score' => $pitta_score,
'kapha_score' => $kapha_score,
'balanced_score' => $balanced_score,
'digestive_score' => $digestive_score,
'mental_score' => $mental_score,
'lifestyle_score' => $lifestyle_score,
'overall_score' => $overall_score,
'digestive_text' => scoreText($digestive_score),
'mental_text' => scoreText($mental_score),
'lifestyle_text' => scoreText($lifestyle_score),
'overall_text' => scoreText($overall_score),
'suggestions' => $suggestions
]
]);
exit;
}
function savevedio($conn)
{
if (!isset($_SESSION['doctor_id'])) {
echo json_encode(['status' => 0, 'msg' => 'Session expired']);
exit;
}
$doctor_id = $_SESSION['doctor_id'];
$id = $_POST['id'] ?? '';
$link = mysqli_real_escape_string($conn, $_POST['link']);
$category_id = mysqli_real_escape_string($conn, $_POST['category_id']);
$tittle = mysqli_real_escape_string($conn, $_POST['tittle']);
$short_description = mysqli_real_escape_string($conn, $_POST['short_description']);
if ($id) {
// UPDATE
$sql = "UPDATE tbl_vedio SET
link='$link',category_id = '$category_id',tittle='$tittle',short_description = '$short_description'
WHERE id='$id'";
} else {
// INSERT
$sql = "INSERT INTO tbl_vedio
(doctor_id,link,category_id,tittle,short_description)
VALUES
('$doctor_id','$link','$category_id','$tittle','$short_description')";
}
// 🔥 EXECUTE + ERROR CHECK
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Saved Successfully']);
} else {
echo json_encode([
'status' => 0,
'msg' => 'DB Error: ' . mysqli_error($conn)
]);
}
exit;
}
function saveSellerRegistration($conn)
{
header('Content-Type: application/json');
$company_name = trim($_POST['company_name'] ?? '');
$brand_name = trim($_POST['brand_name'] ?? '');
$gst_number = trim($_POST['gst_number'] ?? '');
$license_number = trim($_POST['license_number'] ?? '');
$pan_number = trim($_POST['pan_number'] ?? '');
$company_address = trim($_POST['company_address'] ?? '');
$contact_person_name = trim($_POST['contact_person_name'] ?? '');
$phone_number = trim($_POST['phone_number'] ?? '');
$email_id = trim($_POST['email_id'] ?? '');
$bank_name = trim($_POST['bank_name'] ?? '');
$account_holder_name = trim($_POST['account_holder_name'] ?? '');
$account_number = trim($_POST['account_number'] ?? '');
$ifsc_code = trim($_POST['ifsc_code'] ?? '');
$logistics_type = trim($_POST['logistics_type'] ?? '');
if (
$company_name == '' || $brand_name == '' || $gst_number == '' || $license_number == '' ||
$pan_number == '' || $company_address == '' || $contact_person_name == '' ||
$phone_number == '' || $email_id == '' || $bank_name == '' ||
$account_holder_name == '' || $account_number == '' || $ifsc_code == '' || $logistics_type == ''
) {
echo json_encode([
'status' => 0,
'msg' => 'Please fill all required fields.'
]);
exit;
}
if (!filter_var($email_id, FILTER_VALIDATE_EMAIL)) {
echo json_encode([
'status' => 0,
'msg' => 'Please enter a valid email address.'
]);
exit;
}
if (!preg_match('/^[0-9]{10}$/', $phone_number)) {
echo json_encode([
'status' => 0,
'msg' => 'Please enter a valid 10 digit phone number.'
]);
exit;
}
$check = mysqli_prepare($conn, "SELECT id FROM tbl_seller_registration WHERE email_id = ? OR phone_number = ?");
mysqli_stmt_bind_param($check, "ss", $email_id, $phone_number);
mysqli_stmt_execute($check);
mysqli_stmt_store_result($check);
if (mysqli_stmt_num_rows($check) > 0) {
echo json_encode([
'status' => 0,
'msg' => 'Seller already registered with this email or phone number.'
]);
exit;
}
$stmt = mysqli_prepare($conn, "INSERT INTO tbl_seller_registration
(company_name, brand_name, gst_number, license_number, pan_number, company_address, contact_person_name, phone_number, email_id, bank_name, account_holder_name, account_number, ifsc_code, logistics_type, status, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, NOW())");
mysqli_stmt_bind_param(
$stmt,
"ssssssssssssss",
$company_name,
$brand_name,
$gst_number,
$license_number,
$pan_number,
$company_address,
$contact_person_name,
$phone_number,
$email_id,
$bank_name,
$account_holder_name,
$account_number,
$ifsc_code,
$logistics_type
);
if (mysqli_stmt_execute($stmt)) {
echo json_encode([
'status' => 1,
'msg' => 'Seller registration submitted successfully. Your account is pending for approval.'
]);
} else {
echo json_encode([
'status' => 0,
'msg' => 'Something went wrong. Please try again.'
]);
}
exit;
}
function saveFaq($conn)
{
// session_start();
if (!isset($_SESSION['doctor_id'])) {
echo json_encode(['status' => 0, 'msg' => 'Session expired']);
exit;
}
$doctor_id = $_SESSION['doctor_id'];
$id = $_POST['id'] ?? '';
$question = mysqli_real_escape_string($conn, $_POST['question']);
$answer = mysqli_real_escape_string($conn, $_POST['answer']);
if ($id) {
$sql = "UPDATE tbl_faq SET
question='$question',
answer='$answer'
WHERE id='$id'";
} else {
// INSERT
$sql = "INSERT INTO tbl_faq
(doctor_id,question,answer)
VALUES
('$doctor_id','$question','$answer')";
}
// 🔥 EXECUTE + ERROR CHECK
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Saved Successfully']);
} else {
echo json_encode([
'status' => 0,
'msg' => 'DB Error: ' . mysqli_error($conn)
]);
}
exit;
}
function saveTest($conn)
{
// session_start();
if (!isset($_SESSION['doctor_id'])) {
echo json_encode(['status' => 0, 'msg' => 'Session expired']);
exit;
}
$doctor_id = $_SESSION['doctor_id'];
$id = $_POST['id'] ?? '';
$name = mysqli_real_escape_string($conn, $_POST['name']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$post = mysqli_real_escape_string($conn, $_POST['post']);
$image = '';
// IMAGE UPLOAD
if (!empty($_FILES['image']['name'])) {
$image = time() . "_" . $_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], "../media/image/" . $image);
}
if ($id) {
// UPDATE
if (!empty($image)) {
$sql = "UPDATE tbl_testimonial SET
name='$name',
post='$post',
description='$description',
image1='$image'
WHERE id='$id'";
} else {
$sql = "UPDATE tbl_testimonial SET
name='$name',
post='$post',
description='$description'
WHERE id='$id'";
}
} else {
// INSERT
$sql = "INSERT INTO tbl_testimonial
(doctor_id,name,post,description,image1)
VALUES
('$doctor_id','$name','$post','$description','$image')";
}
// 🔥 EXECUTE + ERROR CHECK
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Saved Successfully']);
} else {
echo json_encode([
'status' => 0,
'msg' => 'DB Error: ' . mysqli_error($conn)
]);
}
exit;
}
function deleteData1($conn)
{
$table = $_POST['table'];
$id = $_POST['id'];
if (empty($table) || empty($id)) {
echo json_encode(['status' => 0, 'msg' => 'Invalid request']);
exit;
}
$sql = "DELETE FROM $table WHERE id='$id'";
if (mysqli_query($conn, $sql)) {
echo json_encode(['status' => 1, 'msg' => 'Deleted Successfully']);
} else {
echo json_encode(['status' => 0, 'msg' => mysqli_error($conn)]);
}
exit;
}
function addAppointment($conn)
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$date = date('Y-m-d');
$sql = "insert into tbl_doctor_consultation(name,email,phone,message,date) values('$name','$email','$phone','$message','$date')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for consultation";
} else {
echo "Please try again.";
}
}
// function sendOTP($conn)
// {
// $_SESSION['otp'] = $otp = rand(1000, 9999);
// $_SESSION['email'] = $email = $_POST['email'];
// $to = $email;
// echo "OTP has been send your register email id";
// $subject = 'Login with OTP';
// $message = "Your OTP is {$otp}";
// // To send HTML mail, the Content-type header must be set
// $headers = 'MIME-Version: 1.0' . "\r\n";
// $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// $headers .= 'From: Civic Welllife
' . "\r\n";
// // Mail it
// $flgSend = @mail($to, $subject, $message, $headers);
// }
function login($conn)
{
$cemail = mysqli_real_escape_string($conn, $_POST['email']);
$otp = mysqli_real_escape_string($conn, $_POST['otp']);
global $tblCustomer;
$sql = mysqli_query($conn, "select * from tbl_customer where email='$cemail'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_array($sql);
extract($row);
if ($_SESSION['email'] == $cemail && $_SESSION['otp'] == $otp) {
$customerID = $row['id'];
$_SESSION['customer_id'] = $row['id'];
$_SESSION['customer_name'] = $row['name'];
$_SESSION['customer_email'] = $row['email'];
$_SESSION['customer_phone'] = $row['phone'];
echo '1';
} else {
echo "you have enter wrong email id and otp";
}
} else {
$sql1 = "insert into tbl_customer(email) values('$cemail')";
if (mysqli_query($conn, $sql1) or die(mysqli_error($conn))) {
$sql = mysqli_query($conn, "select * from tbl_customer where email='$cemail'") or die(mysqli_error($conn));
$row = mysqli_fetch_array($sql);
//echo "{$_SESSION['email']}:{$cemail} == {$_SESSION['otp']}: {$otp}";
if ($_SESSION['email'] == $cemail && $_SESSION['otp'] == $otp) {
$customerID = $row['id'];
$_SESSION['customer_id'] = $row['id'];
$_SESSION['customer_name'] = $row['name'];
$_SESSION['customer_email'] = $row['email'];
$_SESSION['customer_phone'] = $row['phone'];
echo '1';
}
}
}
}
function getSearchData($conn)
{
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sqlc = mysqli_query($conn, "select * from tbl_product where name like '%$search%'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
while ($rowc = mysqli_fetch_assoc($sqlc)) {
echo "";
}
} else {
echo "No Record
";
}
}
function setLocation()
{
$_SESSION['city_name'] = $_POST['c'];
$_SESSION['city_id'] = $_POST['cid'];
$_SESSION['location_name'] = $_POST['l'];
$_SESSION['location_id'] = $_POST['lid'];
}
function multiTask($conn)
{
$key_data[] = "name";
$key_data[] = "phone";
$key_data[] = "email";
$key_data[] = "address";
$tableName = "tbl_banner";
$reciveData = array();
foreach ($key_data as $key) {
$value = mysqli_real_escape_string($conn, $_GET[$key]);
$reciveData[$key] = "'{$value}'";
}
// =========== Insert Query ===========
$insertKey = implode(',', $key_data);
$insertValue = implode(',', $reciveData);
$sql = "insert into $tableName($insertKey) values($insertValue)";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
}
// =========== End Query ===========
$updateStringAry = array();
foreach ($reciveData as $key => $value) {
$updateStringAry[] = "{$key}={$value}";
}
$updateString = implode(',', $updateStringAry);
$updateValue = "update {$tableName} set {$updateString} where id = '{$id}'";
// ================= Update =================
$sqladd = mysqli_query($conn, $insertValue) or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
}
// ================= Update =================
}
function otpVerification($conn)
{
$responsee = array();
$finalJSONAry['data'] = array();
$phone = strtolower(mysqli_real_escape_string($conn, $_POST['phone']));
global $tblCustomer;
$sql = mysqli_query($conn, "select * from $tblCustomer where phone='$phone' ") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
$responsee['otp'] = "";
$responsee['message'] = "This mobile Already registered";
$responsee['status'] = "0";
array_push($finalJSONAry['data'], $responsee);
echo json_encode($finalJSONAry);
} else {
$otp = rand(1111, 9999);
/*
$username = urlencode("u58924");
$msg_token = urlencode("361KTo");
$sender_id = urlencode("SWAHER"); // optional (compulsory in transactional sms)
$message = "Thank+You+for+placing+order+At+Swami+herbal+ayurveda+you+are+order+ID+".$otp."+is+confirmed+will+be+dispatched+in+24+hours.%0D%0ARegards+-+Swami+Herbal+Ayurveda.";
$mobile = urlencode($phone);
$api = "http://marketing.eadwinetech.com/api/send_transactional_sms.php?username=".$username."&msg_token=".$msg_token."&sender_id=".$sender_id."&message=".$message."&mobile=".$mobile."";
$response = file_get_contents($api);
*/
$responsee['otp'] = $otp;
$responsee['message'] = "Verification code has been send your no";
$responsee['status'] = "1";
array_push($finalJSONAry['data'], $responsee);
echo json_encode($finalJSONAry);
}
}
function getLocalArea($conn)
{
$city_id = $_POST['cityid'];
$city_name = $_POST['city_name'];
$sqlc = mysqli_query($conn, "select * from tbl_local_area where city_id='$city_id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
while ($rowc = mysqli_fetch_assoc($sqlc)) {
echo "
{$rowc['name']}
";
}
}
}
function addCart($conn)
{ /*
flag=1 - addcart
flag=2 - editcart */
$flag = 1;
// =====================Json Regarding variable =====
$responsee = array();
$finalTotalRecordAry['data'] = array();
// =========================================
if (isset($_SESSION['customer_id'])) {
$customerid = $_SESSION['customer_id'];
if (isset($_SESSION['rand'])) {
$order_id = $_SESSION['rand'];
$flag = 2;
} else {
$rand = getUID();
$order_id = $_SESSION['rand'] = $rand;
}
} else {
$customerid = "0";
if (isset($_SESSION['rand'])) {
$order_id = $_SESSION['rand'];
$flag = 2;
} else {
$rand = date('Ymdhis') . rand(100, 999);
$order_id = $_SESSION['rand'] = $rand;
}
}
global $tblProduct;
global $tblOrder;
global $tblOrderDetails;
// =======================
$quantity = mysqli_real_escape_string($conn, $_POST['quantity']);
$product_id = mysqli_real_escape_string($conn, $_POST['productid']);
// ==============================
$sqlm1 = mysqli_query($conn, "select * from $tblProduct where id='$product_id' ") or die(mysqli_error($conn));
$row = mysqli_fetch_assoc($sqlm1);
$sale_price = $row['sale_price'];
$mrp = $row['mrp'];
$shipping_charge = $row['shipping_charge'];
$size = $row['product_size'];
$total = $sale_price * $quantity;
$referral_code = "";
$point = "";
if (isset($_SESSION['v'])) {
$referral_code = $_SESSION['v'];
$point = $row['point'];
}
// =======================================
$orderDate = date('Y-m-d');
$displayTime = date("h:i:sa");
if ($flag == 1) {
//----------------------------------
$sql = "insert into $tblOrder(order_id,customer_id,order_date,order_time,affiliate_code) values('$order_id','$customerid','$orderDate','$displayTime','$referral_code')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
// ================ insert product in product details ===============
$sqls = "insert into $tblOrderDetails(order_id,product_id,quantity,shipping_charge,sale_price,mrp,size,total,referral_code,point)
values('$order_id','$product_id','$quantity','$shipping_charge','$sale_price','$mrp','$size','$total','$referral_code','$point')";
if (mysqli_query($conn, $sqls) or die(mysqli_error($conn))) {
$totalCartValue = getCartValue($conn, $order_id);
$cartAry = explode('@', $totalCartValue);
$responsee['cart'] = $cartAry[0];
$responsee['cart_quantity'] = $cartAry[1];
$responsee['cart_total'] = $cartAry[2];
$responsee['message'] = "Success";
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
}
//===================================================================
}
//----------------------------------
} else if ($flag == 2) {
//------------------------------------------------
$sqlc = mysqli_query($conn, "select * from $tblOrderDetails where
order_id='$order_id' and product_id='$product_id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
$sqladd = mysqli_query($conn, "update $tblOrderDetails set
quantity='$quantity',
total='$total' where order_id = '$order_id'
and product_id = '$product_id' ") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
}
$totalCartValue = getCartValue($conn, $order_id);
$cartAry = explode('@', $totalCartValue);
$responsee['cart'] = $cartAry[0];
$responsee['cart_quantity'] = $cartAry[1];
$responsee['cart_total'] = $cartAry[2];
$responsee['message'] = "Success";
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
} else {
$sqls = "insert into $tblOrderDetails(order_id,product_id,quantity,shipping_charge,sale_price,mrp,size,total,referral_code,point)
values('$order_id','$product_id','$quantity','$shipping_charge','$sale_price','$mrp','$size','$total','$referral_code','$point')";
if (mysqli_query($conn, $sqls) or die(mysqli_error($conn))) {
$totalCartValue = getCartValue($conn, $order_id);
$cartAry = explode('@', $totalCartValue);
$responsee['cart'] = $cartAry[0];
$responsee['cart_quantity'] = $cartAry[1];
$responsee['cart_total'] = $cartAry[2];
$responsee['message'] = "Success";
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
}
}
//------------------------------------------------
}
}
function addtoCart($conn)
{
global $tblOrderDetails;
$order_id = $_SESSION['rand'];
$quantity = mysqli_real_escape_string($conn, $_POST['quantity']);
$productid = mysqli_real_escape_string($conn, $_POST['productid']);
$sqladd = mysqli_query($conn, "update $tblOrderDetails set
quantity='$quantity'
where order_id = '$order_id'
and id = '$productid'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "0";
}
}
function getCartValue($conn, $orderKey)
{
global $tblProduct;
global $tblOrderDetails;
global $websiteLink;
$totalQuantity = 0;
$totalAmount = 0;
$sqlc = mysqli_query($conn, "select
(select name from $tblProduct where id=o.product_id ) as product_name,
(select thumb1 from $tblProduct where id=o.product_id ) as product_image,
(select url from $tblProduct where id=o.product_id ) as product_url,
o.* from $tblOrderDetails o
where order_id='$orderKey'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
$totalQuantity = mysqli_num_rows($sqlc);
// =====================================
$header = '';
$body = "";
$totalAmount = 0;
$i = 0;
while ($rowc = mysqli_fetch_assoc($sqlc)) {
$i++;
$totalAmount += $rowc['total'];
$link = "product-detail.php?url={$rowc['product_url']}-{$rowc['product_id']}";
$body .= "
";
}
$body .= "";
$footer = "";
// =====================================
return $header . $body . $footer . "@" . $totalQuantity . "@" . $totalAmount;
} else {
$header = "";
return $header . "@" . $totalQuantity . "@" . $totalAmount;
}
}
function newRegistration($conn)
{
global $tblCustomer;
$name = mysqli_real_escape_string($conn, $_POST['name']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$phone = mysqli_real_escape_string($conn, $_POST['phone']);
$password = mysqli_real_escape_string($conn, md5($_POST['password']));
$sql1 = mysqli_query($conn, "select * from $tblCustomer where email='$email' or phone='$phone'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql1) > 0) {
echo "This Email ID or Phone Number Already registered";
} else {
// ============= Registration ===========
$sql = "insert into $tblCustomer(name,email,phone,password) values('$name','$email','$phone','$password')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
$sqlct = mysqli_query($conn, "select * from $tblCustomer where email='$email'")
or die(mysqli_error($conn));
$rowct = mysqli_fetch_assoc($sqlct);
$customerID = $rowct['id'];
$_SESSION['customer_id'] = $rowct['id'];
$_SESSION['customer_name'] = $rowct['name'];
$_SESSION['customer_email'] = $rowct['email'];
$_SESSION['customer_phone'] = $rowct['phone'];
echo "1";
$otp = '380921';
$namemsg = $_SESSION['customer_name'];
$journalName = str_replace(' ', '+', $namemsg);
$message = "Namaste+" . $journalName . "%2C%0D%0AWelcome+to+Sukhalya+Family%21%0D%0AYour+account+has+been+successfully+created+and+We+are+more+than+happy+to+see+you+at+Sukhalya.%0D%0AYou+may+visit+our+ongoing+Workshops%2C+Courses%2C+Products+%26+Retreats+at+sukhalya.com+%0D%0AWarm+Regards%2C%0D%0ASukhalya+Team";
sendSMS($phone, $message);
sendRegisterMail($conn, $email);
} else {
echo "Server is busy please try Again";
}
// ============= Registration ===========
}
}
function login333($conn)
{
$cemail = mysqli_real_escape_string($conn, $_POST['email']);
$cpassword = mysqli_real_escape_string($conn, md5($_POST['password']));
global $tblCustomer;
$sql = mysqli_query($conn, "select * from $tblCustomer where email='$cemail' and password='$cpassword' ") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_array($sql);
extract($row);
if ($cpassword == $password && strtolower($cemail) == strtolower($email)) {
$customerID = $row['id'];
$_SESSION['customer_id'] = $row['id'];
$_SESSION['customer_name'] = $row['name'];
$_SESSION['customer_email'] = $row['email'];
$_SESSION['customer_phone'] = $row['phone'];
echo '1';
} else {
echo "0";
}
} else {
echo "email id and password not matched";
}
}
function registrationData($conn)
{
$tableName = $_POST['tablename'];
$email = $_POST['email'];
$user_id = $_POST['user_id'];
$sqlc = mysqli_query($conn, "select * from $tableName where email='$email' and user_id='$user_id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "This email already registered";
} else {
//$returnurl = $_POST['returnurl'];
/*-------------------------Image info-----------------------------*/
$imgFlag1 = 0;
$imgFlag2 = 0;
$imgFlag3 = 0;
$imgFlag4 = 0;
$imgFlag5 = 0;
$imgFlag6 = 0;
$image = $_POST['image'];
if ($image == 1) {
$imgFlag1 = 1;
}
if ($image == 2) {
$imgFlag1 = 1;
$imgFlag2 = 1;
}
if ($image == 3) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
}
if ($image == 4) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
}
if ($image == 5) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
}
if ($image == 6) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
$imgFlag6 = 1;
}
$keyAry = array();
$valueAry = array();
$keyString = "";
$valueString = "";
$value = "";
foreach ($_POST['feild'] as $feild_name) {
$keyAry[] = $feild_name;
$value = mysqli_real_escape_string($conn, $_POST[$feild_name]);
$valueAry[] = "'{$value}'";
}
$keyString = implode(',', $keyAry);
$valueString = implode(',', $valueAry);
// ====================Image section ================
function getExtension($str)
{
$i = strrpos($str, ".");
if (!$i) {
return "";
}
$l = strlen($str) - $i;
$ext = substr($str, $i + 1, $l);
return $ext;
}
$no = rand(1, 999);
$tno = rand(1, 999);
global $productPath;
global $productPathThumb;
$ImagePath = "$productPath/";
$ImageThumbPath = "$productPathThumb/";
$imageKey = "";
$imageValue = "";
if ($imgFlag1 == 1) {
$imagefleimagename1 = $_FILES['image1fleimage']['name'];
$imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name'];
// ----------------------------------------
if ($imagefleimagename1 != "") {
$image = $imagefleimagename1;
$uploadedfile = $imagefleimagename1;
$imagefleimagename1 = stripslashes($imagefleimagename1);
$extension = getExtension($imagefleimagename1);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile1 = $no . $imagefleimagename1;
move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath" . $newfile1);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$imageThumbName = $tno . $imagefleimagename1;
$imagefleimagename = "$ImageThumbPath/" . $imageThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 1 end------------////////////
} else {
$newfile1 = "";
$imageThumbName = "";
}
$imageKey = ",image1,thumb1";
$imageValue = ",'{$newfile1}','{$imageThumbName}'";
// ----------------------------------------
}
if ($imgFlag2 == 1) {
$imagefleimagename2 = $_FILES['image2fleimage']['name'];
$imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name'];
// ------------------------------------------------
if ($imagefleimagename2 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename2;
$uploadedfile = $imagefleimagename2;
$imagefleimagename2 = stripslashes($imagefleimagename2);
$extension = getExtension($imagefleimagename2);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile2 = $no . $imagefleimagename2;
move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath" . $newfile2);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image2ThumbName = $tno . $imagefleimagename2;
$imagefleimagename = "$ImageThumbPath/" . $image2ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 2 end------------////////////
} else {
$newfile2 = "";
$image2ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}'";
// ------------------------------------------------
}
if ($imgFlag3 == 1) {
$imagefleimagename3 = $_FILES['image3fleimage']['name'];
$imagefleimagename3_tmp = $_FILES['image3fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename3 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename3;
$uploadedfile = $imagefleimagename3;
$imagefleimagename3 = stripslashes($imagefleimagename3);
$extension = getExtension($imagefleimagename3);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile3 = $no . $imagefleimagename3;
move_uploaded_file($_FILES["image3fleimage"]['tmp_name'], "$ImagePath" . $newfile3);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image3ThumbName = $tno . $imagefleimagename3;
$imagefleimagename = "$ImageThumbPath/" . $image3ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 3 end------------////////////
} else {
$newfile3 = "";
$image3ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag4 == 1) {
$imagefleimagename4 = $_FILES['image4fleimage']['name'];
$imagefleimagename4_tmp = $_FILES['image4fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename4 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename4;
$uploadedfile = $imagefleimagename4;
$imagefleimagename4 = stripslashes($imagefleimagename4);
$extension = getExtension($imagefleimagename4);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile4 = $no . $imagefleimagename4;
move_uploaded_file($_FILES["image4fleimage"]['tmp_name'], "$ImagePath" . $newfile4);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image4ThumbName = $tno . $imagefleimagename4;
$imagefleimagename = "$ImageThumbPath/" . $image4ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 4 end------------////////////
} else {
$newfile4 = "";
$image4ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag5 == 1) {
$imagefleimagename5 = $_FILES['image5fleimage']['name'];
$imagefleimagename5_tmp = $_FILES['image5fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename5 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename5;
$uploadedfile = $imagefleimagename5;
$imagefleimagename5 = stripslashes($imagefleimagename5);
$extension = getExtension($imagefleimagename5);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile5 = $no . $imagefleimagename5;
move_uploaded_file($_FILES["image5fleimage"]['tmp_name'], "$ImagePath" . $newfile5);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image5ThumbName = $tno . $imagefleimagename5;
$imagefleimagename = "$ImageThumbPath/" . $image5ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 5 end------------////////////
} else {
$newfile5 = "";
$image5ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag6 == 1) {
$imagefleimagename6 = $_FILES['image6fleimage']['name'];
$imagefleimagename6_tmp = $_FILES['image6fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename6 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename6;
$uploadedfile = $imagefleimagename6;
$imagefleimagename6 = stripslashes($imagefleimagename6);
$extension = getExtension($imagefleimagename6);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile6 = $no . $imagefleimagename6;
move_uploaded_file($_FILES["image6fleimage"]['tmp_name'], "$ImagePath" . $newfile6);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image6ThumbName = $tno . $imagefleimagename6;
$imagefleimagename = "$ImageThumbPath/" . $image6ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 6 end------------////////////
} else {
$newfile6 = "";
$image6ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5,image6,thumb6";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}','{$newfile6}','{$image6ThumbName}'";
// ----------------------------------------------
}
// ====================Insert Section ================
$insertKey = $keyString . '' . $imageKey;
$insertValue = $valueString . "" . $imageValue;
$sql = "insert into $tableName($insertKey) values($insertValue)";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
//header('Location: ../'.$returnurl.'?m=1');
echo "1";
} else {
// header('Location: ../'.$returnurl.'?m=0');
echo "0";
}
}
}
function addData($conn)
{
$tableName = $_POST['tablename'];
//$returnurl = $_POST['returnurl'];
/*-------------------------Image info-----------------------------*/
$imgFlag1 = 0;
$imgFlag2 = 0;
$imgFlag3 = 0;
$imgFlag4 = 0;
$imgFlag5 = 0;
$imgFlag6 = 0;
$image = $_POST['image'];
if ($image == 1) {
$imgFlag1 = 1;
}
if ($image == 2) {
$imgFlag1 = 1;
$imgFlag2 = 1;
}
if ($image == 3) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
}
if ($image == 4) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
}
if ($image == 5) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
}
if ($image == 6) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
$imgFlag6 = 1;
}
$keyAry = array();
$valueAry = array();
$keyString = "";
$valueString = "";
$value = "";
foreach ($_POST['feild'] as $feild_name) {
$keyAry[] = $feild_name;
$value = mysqli_real_escape_string($conn, $_POST[$feild_name]);
$valueAry[] = "'{$value}'";
}
$keyString = implode(',', $keyAry);
$valueString = implode(',', $valueAry);
// ====================Image section ================
function getExtension($str)
{
$i = strrpos($str, ".");
if (!$i) {
return "";
}
$l = strlen($str) - $i;
$ext = substr($str, $i + 1, $l);
return $ext;
}
$no = rand(1, 999);
$tno = rand(1, 999);
global $productPath;
global $productPathThumb;
$ImagePath = "$productPath/";
$ImageThumbPath = "$productPathThumb/";
$imageKey = "";
$imageValue = "";
if ($imgFlag1 == 1) {
$imagefleimagename1 = $_FILES['image1fleimage']['name'];
$imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name'];
// ----------------------------------------
if ($imagefleimagename1 != "") {
$image = $imagefleimagename1;
$uploadedfile = $imagefleimagename1;
$imagefleimagename1 = stripslashes($imagefleimagename1);
$extension = getExtension($imagefleimagename1);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile1 = $no . $imagefleimagename1;
move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath" . $newfile1);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$imageThumbName = $tno . $imagefleimagename1;
$imagefleimagename = "$ImageThumbPath/" . $imageThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 1 end------------////////////
} else {
$newfile1 = "";
$imageThumbName = "";
}
$imageKey = ",image1,thumb1";
$imageValue = ",'{$newfile1}','{$imageThumbName}'";
// ----------------------------------------
}
if ($imgFlag2 == 1) {
$imagefleimagename2 = $_FILES['image2fleimage']['name'];
$imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name'];
// ------------------------------------------------
if ($imagefleimagename2 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename2;
$uploadedfile = $imagefleimagename2;
$imagefleimagename2 = stripslashes($imagefleimagename2);
$extension = getExtension($imagefleimagename2);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile2 = $no . $imagefleimagename2;
move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath" . $newfile2);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image2ThumbName = $tno . $imagefleimagename2;
$imagefleimagename = "$ImageThumbPath/" . $image2ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 2 end------------////////////
} else {
$newfile2 = "";
$image2ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}'";
// ------------------------------------------------
}
if ($imgFlag3 == 1) {
$imagefleimagename3 = $_FILES['image3fleimage']['name'];
$imagefleimagename3_tmp = $_FILES['image3fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename3 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename3;
$uploadedfile = $imagefleimagename3;
$imagefleimagename3 = stripslashes($imagefleimagename3);
$extension = getExtension($imagefleimagename3);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile3 = $no . $imagefleimagename3;
move_uploaded_file($_FILES["image3fleimage"]['tmp_name'], "$ImagePath" . $newfile3);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image3ThumbName = $tno . $imagefleimagename3;
$imagefleimagename = "$ImageThumbPath/" . $image3ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 3 end------------////////////
} else {
$newfile3 = "";
$image3ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag4 == 1) {
$imagefleimagename4 = $_FILES['image4fleimage']['name'];
$imagefleimagename4_tmp = $_FILES['image4fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename4 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename4;
$uploadedfile = $imagefleimagename4;
$imagefleimagename4 = stripslashes($imagefleimagename4);
$extension = getExtension($imagefleimagename4);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile4 = $no . $imagefleimagename4;
move_uploaded_file($_FILES["image4fleimage"]['tmp_name'], "$ImagePath" . $newfile4);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image4ThumbName = $tno . $imagefleimagename4;
$imagefleimagename = "$ImageThumbPath/" . $image4ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 4 end------------////////////
} else {
$newfile4 = "";
$image4ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag5 == 1) {
$imagefleimagename5 = $_FILES['image5fleimage']['name'];
$imagefleimagename5_tmp = $_FILES['image5fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename5 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename5;
$uploadedfile = $imagefleimagename5;
$imagefleimagename5 = stripslashes($imagefleimagename5);
$extension = getExtension($imagefleimagename5);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile5 = $no . $imagefleimagename5;
move_uploaded_file($_FILES["image5fleimage"]['tmp_name'], "$ImagePath" . $newfile5);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image5ThumbName = $tno . $imagefleimagename5;
$imagefleimagename = "$ImageThumbPath/" . $image5ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 5 end------------////////////
} else {
$newfile5 = "";
$image5ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}'";
// ----------------------------------------------
}
if ($imgFlag6 == 1) {
$imagefleimagename6 = $_FILES['image6fleimage']['name'];
$imagefleimagename6_tmp = $_FILES['image6fleimage']['tmp_name'];
// ----------------------------------------------
if ($imagefleimagename6 != "") {
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename6;
$uploadedfile = $imagefleimagename6;
$imagefleimagename6 = stripslashes($imagefleimagename6);
$extension = getExtension($imagefleimagename6);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product.php?m=3');
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setheight = 400;
$ratio = 0.0;
/*if($width>$setwidth){
$ratio=$setwidth/$width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight = $height ;
$newwidth = $width ;
}*/
if ($height > $setheight) {
$ratio = $setheight / $height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$newfile6 = $no . $imagefleimagename6;
move_uploaded_file($_FILES["image6fleimage"]['tmp_name'], "$ImagePath" . $newfile6);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$image6ThumbName = $tno . $imagefleimagename6;
$imagefleimagename = "$ImageThumbPath/" . $image6ThumbName;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Image 6 end------------////////////
} else {
$newfile6 = "";
$image6ThumbName = "";
}
$imageKey = ",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5,image6,thumb6";
$imageValue = ",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}','{$newfile6}','{$image6ThumbName}'";
// ----------------------------------------------
}
// ====================Insert Section ================
$insertKey = $keyString . '' . $imageKey;
$insertValue = $valueString . "" . $imageValue;
$sql = "insert into $tableName($insertKey) values($insertValue)";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
//header('Location: ../'.$returnurl.'?m=1');
echo "1";
} else {
// header('Location: ../'.$returnurl.'?m=0');
echo "0";
}
}
function editData($conn)
{
$id = $_POST['txtid'];
$tableName = $_POST['tablename'];
$returnurl = $_POST['returnurl'];
/*-------------------------Image info-----------------------------*/
$imgFlag1 = 0;
$imgFlag2 = 0;
$imgFlag3 = 0;
$imgFlag4 = 0;
$imgFlag5 = 0;
$imgFlag6 = 0;
$image = $_POST['image'];
if ($image == 1) {
$imgFlag1 = 1;
}
if ($image == 2) {
$imgFlag1 = 1;
$imgFlag2 = 1;
}
if ($image == 3) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
}
if ($image == 4) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
}
if ($image == 5) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
}
if ($image == 6) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
$imgFlag6 = 1;
}
$keyAry = array();
$valueAry = array();
$flag = 0;
$updateString = "";
foreach ($_POST['feild'] as $feild_name) {
$value = mysqli_real_escape_string($conn, $_POST[$feild_name]);
if ($flag == 0) {
$flag = 1;
$updateString .= "{$feild_name}='{$value}'";
} else {
$updateString .= ",{$feild_name}='{$value}'";
}
}
// ====================Image section ================
function getExtension($str)
{
$i = strrpos($str, ".");
if (!$i) {
return "";
}
$l = strlen($str) - $i;
$ext = substr($str, $i + 1, $l);
return $ext;
}
$no = rand(1, 999);
$tno = rand(1, 999);
global $productPath;
global $productPathThumb;
$ImagePath = "$productPath/";
$ImageThumbPath = "$productPathThumb/";
$imageString = "";
// ===============================
$sel = mysqli_query($conn, "select * from $tableName where id = '$id' ");
$row = mysqli_fetch_assoc($sel);
/*---------------------------*/
$flagImage1 = 0;
$flagImage2 = 0;
$flagImage3 = 0;
$flagImage4 = 0;
$flagImage5 = 0;
$flagImage6 = 0;
// =============================
if ($imgFlag1 == 1) {
$imagefleimagename1 = $_FILES['image1fleimage']['name'];
$imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name'];
// ----------------------------------------
$Un_OrginalImage1 = $row['image1'];
$Un_Image1 = $row['thumb1'];
/*--------------insert record varible record------------*/
$InsertImage1 = $row['image1'];
$InsertImagethumb1 = $row['thumb1'];
if ($imagefleimagename1 != "") {
$flagImage1 = 1;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename1;
$uploadedfile = $imagefleimagename1;
$imagefleimagename1 = stripslashes($imagefleimagename1);
$extension = getExtension($imagefleimagename1);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename1_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
$InsertImage1 = $no . $imagefleimagename1;
move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath" . $InsertImage1);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb1 = $tno . $imagefleimagename1;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb1;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
$imageString = " ,image1='{$InsertImage1}',thumb1='{$InsertImagethumb1}'";
// ----------------------------------------
}
if ($imgFlag2 == 1) {
$imagefleimagename2 = $_FILES['image2fleimage']['name'];
$imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name'];
// ------------------------------------------------
$Un_OrginalImage2 = $row['image2'];
$Un_Image2 = $row['thumb2'];
$InsertImage2 = $row['image2'];
$InsertImagethumb2 = $row['thumb2'];
if ($imagefleimagename2 != "") {
$flagImage2 = 2;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename2;
$uploadedfile = $imagefleimagename2;
$imagefleimagename2 = stripslashes($imagefleimagename2);
$extension = getExtension($imagefleimagename2);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename2_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
/*if($height>$setheight){
$ratio=$setheight/$height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight =350;
}*/
$InsertImage2 = $no . $imagefleimagename2;
move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath" . $InsertImage2);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb2 = $tno . $imagefleimagename2;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb2;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
$imageString .= " ,image2='{$InsertImage2}',thumb2='{$InsertImagethumb2}'";
// ------------------------------------------------
}
if ($imgFlag3 == 1) {
$imagefleimagename3 = $_FILES['image3fleimage']['name'];
$imagefleimagename3_tmp = $_FILES['image3fleimage']['tmp_name'];
// ----------------------------------------------
$Un_OrginalImage3 = $row['image3'];
$Un_Image3 = $row['thumb3'];
$InsertImage3 = $row['image3'];
$InsertImagethumb3 = $row['thumb3'];
if ($imagefleimagename3 != "") {
$flagImage3 = 3;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename3;
$uploadedfile = $imagefleimagename3;
$imagefleimagename3 = stripslashes($imagefleimagename3);
$extension = getExtension($imagefleimagename3);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename3_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
/*if($height>$setheight){
$ratio=$setheight/$height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight =350;
}*/
$InsertImage3 = $no . $imagefleimagename3;
move_uploaded_file($_FILES["image3fleimage"]['tmp_name'], "$ImagePath" . $InsertImage3);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb3 = $tno . $imagefleimagename3;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb3;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
$imageString .= " ,image3='{$InsertImage3}',thumb3='{$InsertImagethumb3}'";
// ----------------------------------------------
}
if ($imgFlag4 == 1) {
$imagefleimagename4 = $_FILES['image4fleimage']['name'];
$imagefleimagename4_tmp = $_FILES['image4fleimage']['tmp_name'];
// ----------------------------------------------
$Un_OrginalImage4 = $row['image4'];
$Un_Image4 = $row['thumb4'];
$InsertImage4 = $row['image4'];
$InsertImagethumb4 = $row['thumb4'];
// ======================= image 4 =========================
if ($imagefleimagename4 != "") {
$flagImage4 = 4;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename4;
$uploadedfile = $imagefleimagename4;
$imagefleimagename4 = stripslashes($imagefleimagename4);
$extension = getExtension($imagefleimagename4);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename4_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
/*if($height>$setheight){
$ratio=$setheight/$height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight =350;
}*/
$InsertImage4 = $no . $imagefleimagename4;
move_uploaded_file($_FILES["image4fleimage"]['tmp_name'], "$ImagePath" . $InsertImage4);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb4 = $tno . $imagefleimagename4;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb4;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
//================================ Image 4 End==============================
$imageString .= " ,image4='{$InsertImage4}',thumb4='{$InsertImagethumb4}'";
// ----------------------------------------------
}
if ($imgFlag5 == 1) {
$imagefleimagename5 = $_FILES['image5fleimage']['name'];
$imagefleimagename5_tmp = $_FILES['image5fleimage']['tmp_name'];
// ----------------------------------------------
$Un_OrginalImage5 = $row['image5'];
$Un_Image5 = $row['thumb5'];
$InsertImage5 = $row['image5'];
$InsertImagethumb5 = $row['thumb5'];
// ======================= image 5 =========================
if ($imagefleimagename5 != "") {
$flagImage5 = 5;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename5;
$uploadedfile = $imagefleimagename5;
$imagefleimagename5 = stripslashes($imagefleimagename5);
$extension = getExtension($imagefleimagename5);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename5_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
/*if($height>$setheight){
$ratio=$setheight/$height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight =350;
}*/
$InsertImage5 = $no . $imagefleimagename5;
move_uploaded_file($_FILES["image5fleimage"]['tmp_name'], "$ImagePath" . $InsertImage5);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb5 = $tno . $imagefleimagename5;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb5;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
//================================ Image 5 End==============================
$imageString .= " ,image5='{$InsertImage5}',thumb5='{$InsertImagethumb5}'";
// ----------------------------------------------
}
if ($imgFlag6 == 1) {
$imagefleimagename6 = $_FILES['image6fleimage']['name'];
$imagefleimagename6_tmp = $_FILES['image6fleimage']['tmp_name'];
// ----------------------------------
$Un_OrginalImage6 = $row['image6'];
$Un_Image6 = $row['thumb6'];
$InsertImage6 = $row['image6'];
$InsertImagethumb6 = $row['thumb6'];
// ======================= image 6 =========================
if ($imagefleimagename6 != "") {
$flagImage6 = 6;
//check if image has 2 dot then exit program
//$catfile = $imagefleimagename1;
$image = $imagefleimagename6;
$uploadedfile = $imagefleimagename6;
$imagefleimagename6 = stripslashes($imagefleimagename6);
$extension = getExtension($imagefleimagename6);
$extension = strtolower($extension);
/*-------------------------------*/
/*---------------------------------*/
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) {
header('Location: ../product-list.php?m=16&id=' . $id);
exit();
}
if ($extension == "jpg" || $extension == "jpeg") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefromjpeg($uploadedfile);
} else if ($extension == "png") {
$uploadedfile = $imagefleimagename6_tmp;
$src = imagecreatefrompng($uploadedfile);
} else {
$src = imagecreatefromgif($uploadedfile);
}
list($width, $height) = getimagesize($uploadedfile);
$setwidth = 400;
$ratio = 0.0;
if ($width > $setwidth) {
$ratio = $setwidth / $width;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
} else {
$newheight = $height;
$newwidth = $width;
}
/*if($height>$setheight){
$ratio=$setheight/$height;
$newheight = $height * $ratio; // Reset height to match scaled image
$newwidth = $width * $ratio;
}else{
$newheight =350;
}*/
$InsertImage6 = $no . $imagefleimagename6;
move_uploaded_file($_FILES["image6fleimage"]['tmp_name'], "$ImagePath" . $InsertImage6);
$tmp = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$InsertImagethumb6 = $tno . $imagefleimagename6;
$imagefleimagename = "$ImageThumbPath/" . $InsertImagethumb6;
imagejpeg($tmp, $imagefleimagename, 100);
imagedestroy($src);
imagedestroy($tmp);
//////---------------End Upload Brand Image------------////////////
}
//================================ Image 6 End==============================
$imageString .= " ,image6='{$InsertImage6}',thumb6='{$InsertImagethumb6}'";
// ----------------------------------------------
}
$insertValue = "update {$tableName} set {$updateString} {$imageString} where id = '{$id}'";
$sqladd = mysqli_query($conn, $insertValue) or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
if ($flagImage1 == 1) {
if ($Un_OrginalImage1 != "") {
unlink($ImagePath . $Un_OrginalImage1);
}
}
//header('Location: ../'.$returnurl.'?m=4&id='.$id);
echo "1";
} else {
// header('Location: ../'.$returnurl.'?m=5&id='.$id);
echo "0";
}
}
function deleteData($conn)
{
$id = isset($_GET['id']) ? $_GET['id'] : "";
$image = $_GET['image'];
$tableName = $_GET['tablename'];
$returnurl = $_GET['returnurl'];
$imgFlag1 = 0;
$imgFlag2 = 0;
$imgFlag3 = 0;
$imgFlag4 = 0;
$imgFlag5 = 0;
$imgFlag6 = 0;
if ($image == 1) {
$imgFlag1 = 1;
}
if ($image == 2) {
$imgFlag1 = 1;
$imgFlag2 = 1;
}
if ($image == 3) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
}
if ($image == 4) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
}
if ($image == 5) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
}
if ($image == 6) {
$imgFlag1 = 1;
$imgFlag2 = 1;
$imgFlag3 = 1;
$imgFlag4 = 1;
$imgFlag5 = 1;
$imgFlag6 = 1;
}
// ===================================
if ($image == 0) {
$checkSql = mysqli_query($conn, "select * from $tableName where id ='$id'") or die(mysqli_error($conn));
if (mysqli_num_rows($checkSql) > 0) {
$rowi = mysqli_fetch_assoc($checkSql);
if ($imgFlag1 == 1) {
$image1 = $rowi['image1'];
$thumb1 = $rowi['thumb1'];
}
if ($imgFlag2 == 1) {
$image2 = $rowi['image2'];
$thumb2 = $rowi['thumb2'];
}
if ($imgFlag3 == 1) {
$image3 = $rowi['image3'];
$thumb3 = $rowi['thumb3'];
}
if ($imgFlag4 == 1) {
$image4 = $rowi['image4'];
$thumb4 = $rowi['thumb4'];
}
if ($imgFlag5 == 1) {
$image5 = $rowi['image5'];
$thumb5 = $rowi['thumb5'];
}
if ($imgFlag6 == 1) {
$image6 = $rowi['image6'];
$thumb6 = $rowi['thumb6'];
}
//header('Location: ../product-list.php?&m=15');
//exit();
}
}
//echo "value is ".$id;
global $solePath;
global $solePathThumb;
$ImagePath = "$solePath/";
$ImageThumbPath = "$solePathThumb/";
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from $tableName where id = '$id' ";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
if ($imgFlag1 == 1) {
if ($image1 != "") {
unlink($ImagePath . $image1);
unlink($ImageThumbPath . $thumb1);
}
}
if ($imgFlag2 == 2) {
if ($image2 != "") {
unlink($ImagePath . $image2);
unlink($ImageThumbPath . $thumb2);
}
}
if ($imgFlag3 == 1) {
if ($image3 = "") {
unlink($ImagePath . $image3);
unlink($ImageThumbPath . $thumb3);
}
}
if ($imgFlag4 == 1) {
if ($image4 != "") {
unlink($ImagePath . $image4);
unlink($ImageThumbPath . $thumb4);
}
}
if ($imgFlag5 == 1) {
if ($image5 != "") {
unlink($ImagePath . $image5);
unlink($ImageThumbPath . $thumb5);
}
}
if ($imgFlag6 == 1) {
if ($image6 != "") {
unlink($ImagePath . $image6);
unlink($ImageThumbPath . $thumb6);
}
}
mysqli_query($conn, "COMMIT");
header('Location: ../' . $returnurl . '?&m=6');
} else {
mysqli_query($conn, "ROLLBACK");
header('Location: ../' . $returnurl . '?m=7');
}
// ===================================
}
function editQuantity($conn)
{
$oID = $_POST['orderid'];
$quantity = $_POST['quantity'];
$orderID = $_SESSION['rand'];
/*-----------------------------------------------------------------------*/
$sqladd = mysqli_query($conn, "update tbl_order_details
set quantity = '$quantity'
where order_id = '$orderID' and id='$oID'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "success";
} else {
echo "fail";
}
}
function cancelOrder($conn)
{
$orderID = $_GET['o'];
/*-----------------------------------------------------------------------*/
$sqladd = mysqli_query($conn, "update tbl_order set user_order_status = '1'
where order_id = '$orderID'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
header('Location: ../my-account.php');
// echo "success";
} else {
header('Location: ../my-account.php');
// echo "fail";
}
}
function orderReturn($conn)
{
$orderID = $_POST['oid'];
$reasion = $_POST['txtreasion'];
$status = $_POST['status'];
/*-----------------------------------------------------------------------*/
$sqladd = mysqli_query($conn, "update tbl_order set user_order_status = '$status',
return_reasion='$reasion'
where order_id = '$orderID'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
header('Location: ../my-account.php');
// echo "success";
} else {
header('Location: ../my-account.php');
// echo "fail";
}
}
function changePassword($conn)
{
$email = $_SESSION['customer_email'];
$oldpass = md5($_REQUEST['oldpassword']);
$pass = md5($_REQUEST['newpassword']);
/*-----------------------------------------------------------------------*/
$csql = mysqli_query($conn, "select * from tbl_customer where email = '$email' and password = '$oldpass'");
if (mysqli_num_rows($csql) > 0) {
//echo "change password";
$sqladd = mysqli_query($conn, "update tbl_customer set password = '$pass' where email = '$email'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "Your password has been changed";
} else {
//header('Location: ../dashboard.php?option=chngpswd&m=2');
echo "Not Changed";
}
} else {
echo "You have entered wrong password.";
//header('Location: ../dashboard.php?option=chngpswd&m=3');
}
}
function applyPromo($conn)
{
$promocode = $_POST['promocode'];
$customerID = $_SESSION['customer_id'];
$order_id = $_SESSION['rand'];
$date = date('Y-m-d');
$promo_amount = 0;
/*
1 = Apply
2 = Wrong Promocode
3 =
order_type {1= One time , 2= multiple time}
promo_type {2= flat,1= percentge}
*/
$csql = mysqli_query($conn, "select * from tbl_promocode where name = '$promocode'
and status = '1' and CURDATE() between start_date and end_date") or die(mysqli_error($conn));
if (mysqli_num_rows($csql) > 0) {
$rowc = mysqli_fetch_assoc($csql);
$offer_type = $rowc['offer_type'];
$promo_type = $rowc['promo_type'];
$amount = $rowc['amount'];
$flag = 1;
// =======================
$sql2 = mysqli_query($conn, "select sum(total_price_amount) as total_amount from view_get_order_details where order_id = '$order_id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql2) > 0) {
$row2 = mysqli_fetch_assoc($sql2);
$total_amount = $row2['total_amount'];
} else {
$total_amount = 0;
}
// =======================
if ($offer_type == 1) {
$sql1 = mysqli_query($conn, "select * from tbl_order where customer_id = '$customerID'
and promo_code = '$promocode'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql1) > 0) {
echo "Offer valid for first time";
$flag = 0;
} else {
if ($promo_type == 1) {
$promo_amount = ($total_amount * $amount) / 100;
} else if ($promo_type == 2) {
$promo_amount = $total_amount - $amount;
} else {
echo "Not Valid";
$flag = 0;
}
}
} else {
if ($promo_type == 1) {
$promo_amount = ($total_amount * $amount) / 100;
echo "1";
} else if ($promo_type == 2) {
$promo_amount = $total_amount - $amount;
} else {
echo "Not Valid";
$flag = 0;
}
}
if ($flag == 1) {
$sqladd = mysqli_query($conn, "update tbl_order
set promo_code = '$promocode',
discount = '$amount',
promo_amount = '$promo_amount',
promo_type = '$promo_type'
where order_id = '$order_id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "Already Applyed";
}
}
} else {
echo 'You have entered wrong Promocode';
}
}
function applyPromoPersonal($conn)
{
$promocode = $_POST['promocode'];
$totalAmount = $_POST['totalamount'];
$order_id = $_SESSION['rand'];
$finalPromoDis = 0;
// echo "select * from tbl_promocode where status=1 and min_value<='$totalAmount' and promo_type=2 and promo_name='$promocode'";
$sql = mysqli_query($conn, "select * from tbl_promocode where status=1 and name='$promocode'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_assoc($sql);
// -------------------
$promo_value = $row['amount'];
if ($row['promo_type'] == 2) {
$finalPromoDis = $row['amount'];
} else {
$promoDis = round($row['amount'], 0);
$finalPromoDis = ($totalAmount * $promoDis / 100);
/*$finalPromoDisAmount = ($totalAmount*$promoDis/100);
if($finalPromoDisAmount>=$row['max_amount']){
$finalPromoDis = $row['max_amount'];
}else{
$finalPromoDis = $finalPromoDisAmount;
}
$finalPromoDis*/;
}
// ==========================
$amount = $finalPromoDis;
/*$typeofcoupon = $row['type_coupon'];
if($typeofcoupon==1){*/
$csql = mysqli_query($conn, "select * from tbl_order where
promocode = '$promocode' and order_id = '$order_id'") or die(mysqli_error($conn));
if (mysqli_num_rows($csql) > 0) {
echo 'you have already used';
} else {
// -----------------------------
$sqladd = mysqli_query($conn, "update tbl_order
set promocode = '$promocode',
promo_value='$promo_value',
discount_amount = '$amount'
where order_id = '$order_id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "Already Applyed";
}
// -----------------------------
}
/*}else{
// -----------------------------
$sqladd = mysqli_query($conn,"update tbl_order
set promo_name = '$promocode',
promo_amount = '$amount'
where order_id = '$oid'") or die(mysqli_error($conn));
if(mysqli_affected_rows($conn) > 0)
{
echo "1";
}
else
{
echo "0";
}
// -----------------------------
}*/
// ===========================
// --------------------------
} else {
echo 'Not Valid';
}
}
function removePromo($conn)
{
$oid = $_SESSION['rand'];
$sqladd = mysqli_query($conn, "update tbl_order
set promocode = '',
promo_value = '',
discount_amount ='0'
where order_id = '$oid'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "0";
}
}
function getCity($conn)
{
$stateid = $_POST['stateid'];
echo '';
echo 'select ';
$sqlr = mysqli_query($conn, "select * from tbl_city where state_id='$stateid'") or die(mysqli_error($conn));
while ($rowr = mysqli_fetch_assoc($sqlr)) {
echo '' . $rowr['name'] . ' ';
}
echo ' ';
}
function addSubscribe($conn)
{
$email = $_POST['email'];
$sqlc = mysqli_query($conn, "select * from tbl_subscribe where name='$email'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "You have already subscribe";
} else {
$sql = "insert into tbl_subscribe(name) values('$email')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for subscribe";
} else {
echo "Please try again.";
}
}
}
function forgotPassword($conn)
{
$phone = $_POST['phone'];
$sqladd = mysqli_query($conn, "select * from tbl_customer where phone='$phone' ") or die(mysqli_error($conn));
if (mysqli_num_rows($sqladd) > 0) {
$rand = rand(100000, 999999);
$_SESSION['restet_otp'] = "{$phone}{$rand}";
$message = "Your+OTP+is+" . $rand . "%0D%0ARegards-%0D%0ASukhalya";
sendSMS($phone, $message);
echo "OTP has been sent to your registered mobile number";
} else {
echo "you have entered wrong Phone";
}
}
function resetPassword($conn)
{
$phone = $_POST['phone'];
$otp = $_POST['otp'];
$pass = md5($_POST['password']);
$combine = "{$phone}{$otp}";
/*-----------------------------------------------------------------------*/
if ($combine == $_SESSION['restet_otp']) {
$sqladd = mysqli_query($conn, "update tbl_customer set password = '$pass' where phone = '$phone'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
unset($_SESSION['restet_otp']);
echo 1;
//header('Location: ../login.php?a=1');
} else {
echo "Not Changed";
}
} else {
echo "You Have enter wrong OTP";
}
}
function askQuestion($conn)
{
$question = $_POST['question'];
$productid = $_POST['productid'];
$sql = "insert into tbl_ask(question,product_id) values('$question','$productid')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for asking question";
} else {
echo "Please try again.";
}
}
function addEnquiry($conn)
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$date = date('Y-m-d');
$sql = "insert into tbl_enquiry(name,email,phone,date,message) values('$name','$email','$phone','$date','$message')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for enquiry";
} else {
echo "Please try again.";
}
}
function saveDoctorEnquiry($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['name']);
$phone = mysqli_real_escape_string($conn, $_POST['phone']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$city = mysqli_real_escape_string($conn, $_POST['city']);
$problem_id = (int) $_POST['problem_id'];
$category_id = (int) $_POST['category_id'];
$sql = "
INSERT INTO tbl_doctor_enquiry
(name, phone, email, city, problem_id, category_id)
VALUES
('$name', '$phone', '$email', '$city', '$problem_id', '$category_id')
";
if (mysqli_query($conn, $sql)) {
echo "Thank you for enquiry";
} else {
echo "Please try again.";
}
}
function addDoctor($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['name']);
$gender = mysqli_real_escape_string($conn, $_POST['gender']);
$dob = $_POST['dob'];
$mobile = mysqli_real_escape_string($conn, $_POST['mobile']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$experience = mysqli_real_escape_string($conn, $_POST['experience']);
$hospital_name = mysqli_real_escape_string($conn, $_POST['hospital_name']);
$consultation_fee = mysqli_real_escape_string($conn, $_POST['consultation_fee']);
$address = mysqli_real_escape_string($conn, $_POST['address']);
$timimg = mysqli_real_escape_string($conn, $_POST['timimg']);
$check_mode = mysqli_real_escape_string($conn, $_POST['check_mode']);
$eduaction = mysqli_real_escape_string($conn, $_POST['eduaction']);
$institute = mysqli_real_escape_string($conn, $_POST['institute']);
$about = mysqli_real_escape_string($conn, $_POST['about']);
// Multiple categories
$category_id = '';
if (!empty($_POST['category_id'])) {
$category_id = implode(',', $_POST['category_id']);
}
$problem_id = '';
if (!empty($_POST['problem_id'])) {
$problem_id = implode(',', $_POST['problem_id']);
}
$image1 = '';
if (!empty($_FILES['image1']['name'])) {
$ext = pathinfo($_FILES['image1']['name'], PATHINFO_EXTENSION);
$image1 = 'doctor_' . time() . '.' . $ext;
move_uploaded_file($_FILES['image1']['tmp_name'], '../media/image/' . $image1);
}
$sql = "INSERT INTO tbl_doctor_registration
(name, gender, dob, mobile, email, experience, hospital_name,
consultation_fee, timimg, check_mode, address, category_id, image1,eduaction,problem_id,institute,about)
VALUES
('$name', '$gender', '$dob', '$mobile', '$email', '$experience',
'$hospital_name', '$consultation_fee', '$timimg', '$check_mode',
'$address', '$category_id', '$image1','$eduaction','$problem_id','$institute','$about')";
if (mysqli_query($conn, $sql)) {
echo "Doctor registered successfully";
} else {
echo "Error: " . mysqli_error($conn);
}
}
function sendDoctorOtp($conn)
{
$email = mysqli_real_escape_string($conn, $_POST['email']);
$type = $_POST['type']; // doctor / patient
/* check user exists */
if ($type == "doctor") {
$check = mysqli_query($conn, "
SELECT id FROM tbl_doctor_registration
WHERE email='$email'
");
$notfound = "Doctor not found";
} else {
$check = mysqli_query($conn, "
SELECT id FROM tbl_booking
WHERE patient_email ='$email'
");
$notfound = "Patient not found";
}
if (mysqli_num_rows($check) == 0) {
echo json_encode([
'status' => 'error',
'message' => $notfound
]);
exit;
}
$otp = rand(1000, 9999);
/* session */
$_SESSION['login_otp'] = $otp;
$_SESSION['login_email'] = $email;
$_SESSION['login_type'] = $type;
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.hostinger.com';
$mail->SMTPAuth = true;
$mail->Username = 'connect@overseastradelinker.com';
$mail->Password = '8G=UT1|rSXe';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('connect@overseastradelinker.com', 'Civic WellLife');
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = ucfirst($type) . " Login OTP";
$mail->Body = "Your OTP is: $otp ";
$mail->send();
echo json_encode([
'status' => 'success',
'message' => 'OTP sent successfully'
]);
} catch (Exception $e) {
echo json_encode([
'status' => 'error',
'message' => $mail->ErrorInfo
]);
}
}
// function doctorOtpLogin($conn)
// {
// $email = $_POST['email'];
// $otp = $_POST['otp'];
// if (!isset($_SESSION['doctor_login_otp'])) {
// echo "expired";
// exit;
// }
// if ($otp == $_SESSION['doctor_login_otp'] && $email == $_SESSION['doctor_login_email']) {
// $sql = mysqli_query($conn, "
// SELECT id FROM tbl_doctor_registration
// WHERE email='$email'
// ");
// $row = mysqli_fetch_assoc($sql);
// $_SESSION['doctor_id'] = $row['id'];
// unset($_SESSION['doctor_login_otp']);
// echo "success";
// } else {
// echo "invalid";
// }
// }
function doctorOtpLogin($conn)
{
$email = $_POST['email'];
$otp = $_POST['otp'];
$type = $_POST['login_type']; // doctor / patient
if (!isset($_SESSION['login_otp'])) {
echo "expired";
exit;
}
if ($otp == $_SESSION['login_otp'] && $email == $_SESSION['login_email']) {
if ($type == "doctor") {
$sql = mysqli_query($conn, "
SELECT id FROM tbl_doctor_registration
WHERE email='$email'
");
$row = mysqli_fetch_assoc($sql);
$_SESSION['doctor_id'] = $row['id'];
} else {
// patient login
$_SESSION['patient_email'] = $email;
}
unset($_SESSION['login_otp']);
unset($_SESSION['login_email']);
echo "success";
} else {
echo "invalid";
}
}
function addWorkEnquiry($conn)
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$date = date('Y-m-d');
$sql = "insert into tbl_workshope_enquiry(name,email,phone,date,message) values('$name','$email','$phone','$date','$message')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for enquiry";
} else {
echo "Please try again.";
}
}
function addDealership($conn)
{
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$profession = $_POST['profession'];
$invest = $_POST['invest'];
$message = $_POST['message'];
$date = date('Y-m-d');
$sql = "insert into tbl_dealer(name,email,phone,date,message,profession,amount)
values('$name','$email','$phone','$date','$message','$profession','$invest')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Thank you for enquiry";
} else {
echo "Please try again.";
}
}
function checkPincode($conn)
{
$pincode = $_POST['txtpincode'];
$sqlc = mysqli_query($conn, "select * from tbl_pincode where name='$pincode'") or
die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
$rows = mysqli_fetch_assoc($sqlc);
$time = $rows['delivery_time'];
echo 'Available ' . $time . '
';
} else {
echo 'Not available this area
';
}
}
function getCartValue2($conn, $orderid)
{
$table = "";
$table_col = "";
$totalValue = "";
$table = '
Product
Description
Unit price
Shipping
Total
';
$totalShippingAmount = 0;
$totalFinalAmount = 0;
$sqlw = mysqli_query($conn, "select * from view_get_order_details where order_id='$orderid'") or die(mysqli_error($conn));
while ($roww = mysqli_fetch_assoc($sqlw)) {
$totalShippingAmount += $roww['total_shipping_amount'];
$totalFinalAmount += $roww['total_final_amount'];
$table_col .= '
' . $roww['product_name'] . '
Size : ' . $roww['size'] . '
' . $roww['price'] . '
' . $roww['shipping_charge'] . '
' . $roww['total_final_amount'] . '
';
}
$footer = '
Total Shipping
' . $totalShippingAmount . '
Total Amount
' . $totalFinalAmount . '
payable Amount
' . ($totalFinalAmount + $totalShippingAmount) . '
Continue Shopping
Process to Checkout
';
$totalValue = $table . $table_col . $footer;
// ===============================================
return $totalValue;
}
function editCart($conn)
{
// =====================Json Regarding variable =====
$responsee = array();
$finalTotalRecordAry['data'] = array();
// =========================================
$quantity = mysqli_real_escape_string($conn, $_POST['quantity']);
$cartitemid = mysqli_real_escape_string($conn, $_POST['cartitemid']);
// ================ insert product in product details ===============
$sqlc = mysqli_query($conn, "select * from tbl_order_details where id='$cartitemid'") or die(mysqli_error($conn));
$rowc = mysqli_fetch_assoc($sqlc);
$cartkey = $rowc['uid'];
if (mysqli_num_rows($sqlc) > 0) {
$sqladd = mysqli_query($conn, "update tbl_order_details set
quanitity='$quantity' where id='$cartitemid'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
}
$totalValue = getCartValue($conn, $cartkey);
$responsee['cart'] = $totalValue;
$responsee['message'] = "Success";
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
} else {
$totalValue = getCartValue($conn, $cartkey);
$responsee['cart'] = $totalValue;
$responsee['message'] = "Success";
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
}
//===================================================================
}
function deleteCart($conn)
{
$id = isset($_POST['productid']) ? $_POST['productid'] : "";
$orderid = $_SESSION['rand'];
//echo "value is ".$id;
global $tblOrderDetails;
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from $tblOrderDetails where id = '$id' and order_id='$orderid'";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
mysqli_query($conn, "COMMIT");
// ============================================
$sqls = mysqli_query($conn, "select * from $tblOrderDetails where order_id='$orderid'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqls) > 0) {
echo "1";
} else {
echo "0";
}
// ============================================
} else {
mysqli_query($conn, "ROLLBACK");
// echo "0";
}
}
function deleteCartItem($conn)
{
$id = isset($_POST['productid']) ? $_POST['productid'] : "";
$orderid = $_POST['orderid'];
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from tbl_order_details where id = '$id' ";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
mysqli_query($conn, "COMMIT");
$sqls = mysqli_query($conn, "select * from tbl_order_details where order_id='$orderid'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqls) > 0) {
echo "1";
} else {
echo "2";
}
} else {
echo "0";
}
}
function deleteCart2($conn)
{
$id = isset($_POST['productid']) ? $_POST['productid'] : "";
$orderid = $_POST['orderid'];
// =====================Json Regarding variable =====
$responsee = array();
$finalTotalRecordAry['data'] = array();
// =========================================
//echo "value is ".$id;
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from tbl_order_details where id = '$id' ";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
mysqli_query($conn, "COMMIT");
// ============================================
$sqls = mysqli_query($conn, "select * from tbl_order_details where order_id='$orderid'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqls) > 0) {
$totalCartValue = getCartValue($conn, $orderid);
$cartAry = explode('@', $totalCartValue);
$responsee['cart'] = $cartAry[0];
$responsee['cart_quantity'] = $cartAry[1];
$responsee['cart_total'] = $cartAry[2];
$responsee['status'] = "1";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
} else {
$totalCartValue = getCartValue($conn, $orderid);
$cartAry = explode('@', $totalCartValue);
$responsee['cart'] = $cartAry[0];
$responsee['cart_quantity'] = $cartAry[1];
$responsee['cart_total'] = $cartAry[2];
$responsee['status'] = "0";
array_push($finalTotalRecordAry['data'], $responsee);
echo json_encode($finalTotalRecordAry);
}
// ============================================
// echo "1";
} else {
mysqli_query($conn, "ROLLBACK");
// echo "0";
}
}
function finalPlaceOrder($conn)
{
$cartkey = $_SESSION['rand'];
$orderDate = date('Y-m-d');
$displayTime = date("h:i:sa");
$sqladd = mysqli_query($conn, "update tbl_order_details set
order_amount='$totalAmount',
order_date='$orderDate',
full_date='$displayTime',
cart_status='1' where uid = '$cartkey' and customer_id = '$customerid'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
unset($_SESSION['total_amount']);
unset($_SESSION['rand']);
echo "1";
}
}
function placeOrder($conn)
{
$customer_id = $_SESSION['customer_id'];
$shipping_charge = $_POST['shipping_amount'];
$order_amount = $_POST['total_amount'] - $shipping_charge;
$discount_amount = $_POST['discount_amount'];
$name = mysqli_real_escape_string($conn, $_POST['name']);
// $pincode = mysqli_real_escape_string($conn,$_POST['pincode']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$phone = mysqli_real_escape_string($conn, $_POST['phone']);
/*$address = mysqli_real_escape_string($conn,$_POST['address']);
$landmark = mysqli_real_escape_string($conn,$_POST['landmark']);
$pincode = mysqli_real_escape_string($conn,$_POST['pincode']);
$city = mysqli_real_escape_string($conn,$_POST['city']);
$state = mysqli_real_escape_string($conn,$_POST['state']);*/
$address = "";
$landmark = "";
$pincode = "";
$city = "";
$state = "";
// $mode = mysqli_real_escape_string($conn,$_POST['mode']);
// $shipping_id = mysqli_real_escape_string($conn,$_POST['shipping_id']);
// ===========================
$order_id = $_SESSION['rand'];
$sqladd = mysqli_query($conn, "update tbl_order set
name='$name',
email='$email',
phone='$phone',
address1='$address',
pincode='$pincode',
landmark='$landmark',
order_amount='$order_amount',
shipping_charge='$shipping_charge',
discount_amount='$discount_amount',
city='$city',
state='$state' where order_id = '$order_id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "Cart Is Empty";
}
}
function updateAddress($conn)
{
$orderID = $_POST['order_id'];
$state = mysqli_real_escape_string($conn, $_POST['state']);
$city = mysqli_real_escape_string($conn, $_POST['city']);
$pincode = mysqli_real_escape_string($conn, $_POST['pincode']);
$address = mysqli_real_escape_string($conn, $_POST['address']);
$landmark = mysqli_real_escape_string($conn, $_POST['landmark']);
global $tblOrder;
$sqladd = mysqli_query($conn, "update $tblOrder
set
landmark='$landmark',
address1='$address',
pincode='$pincode',
state='$state',
city='$city'
where order_id = '$orderID' ") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "Done";
} else {
echo "Already Done";
}
}
function updateAddress2($conn)
{
$customerID = $_SESSION['customer_id'];
$state = $_POST['state'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$address = $_POST['address'];
$landmark = $_POST['landmark'];
global $tblShippingAddress;
$sqls = mysqli_query($conn, "select * from $tblShippingAddress where customer_id = '$customerID' ")
or die(mysqli_error($conn));
if (mysqli_num_rows($sqls) > 0) {
$sqladd = mysqli_query($conn, "update $tblShippingAddress
set
landmark='$landmark',
address='$address',
pincode='$pincode',
state='$state',
city='$city'
where customer_id = '$customerID' ") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "Updated";
} else {
echo "Already Updated";
}
} else {
// ======= Insert Record ============
$sql = "insert into $tblShippingAddress(customer_id,landmark,address,pincode,city,state)
values('$customerID','$landmark','$address','$pincode','$city','$state')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "Update address";
} else {
echo "Already Updated";
}
// ==================================
}
}
function unseUser()
{
unset($_SESSION['rand']);
}
function editShipping($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['username']);
$phone = mysqli_real_escape_string($conn, $_POST['userphone']);
$email = mysqli_real_escape_string($conn, $_POST['useremail']);
$pincode = mysqli_real_escape_string($conn, $_POST['pincode']);
$landmark = mysqli_real_escape_string($conn, $_POST['landmark']);
$addressline1 = mysqli_real_escape_string($conn, $_POST['addressline1']);
$addressline2 = mysqli_real_escape_string($conn, $_POST['addressline2']);
$cityStr = mysqli_real_escape_string($conn, $_POST['selcity']);
$orderDate = date('Y-m-d');
$displayTime = date("h:i:sa");
$cityAry = explode(',', $cityStr);
$cityID = $cityAry[0];
$stateID = $cityAry[1];
$country = 1;
$customerID = $_SESSION['customer_id'];
// ============= check shipping address exits or no ===========
$sqladd = mysqli_query($conn, "update tbl_shipping_address
set name='$name',
email='$email',
phone='$phone',
landmark='$landmark',
address_line_1='$addressline1',
address_line_2='$addressline2',
pincode='$pincode',
city_id='$cityID',
state_id='$stateID' where customer_id = '$customerID'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "0";
}
}
function logout($conn)
{
unset($_SESSION['customer_id']);
unset($_SESSION['customer_name']);
unset($_SESSION['customer_email']);
unset($_SESSION['customer_phone']);
unset($_SESSION['customer_image']);
header('Location: ../index.php');
}
function autoLogin($conn)
{
$userToken = $_POST['token'];
if (isset($_SESSION['customer_id'])) {
echo "2";
} else {
$sql = mysqli_query($conn, "select * from tbl_customer_profile where token='$userToken'") or die(mysqli_error($conn));
if (mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_array($sql);
$_SESSION['customer_id'] = $row['id'];
$_SESSION['customer_name'] = $row['name'];
$_SESSION['customer_email'] = $row['email'];
$_SESSION['customer_phone'] = $row['phone'];
$_SESSION['customer_image'] = $row['thumb1'];
echo '1';
}
}
}
// ============================ end new section ==========================================
function checkSku($conn)
{
$id = $_POST['itemid'];
$sku = $_POST['sku'];
if ($id == "") {
$sqlc = mysqli_query($conn, "select * from tbl_item where sku='$sku'") or die(mysqli_query($conn));
} else {
$sqlc = mysqli_query($conn, "select * from tbl_item where sku='$sku' and id!='$id'") or die(mysqli_query($conn));
}
if (mysqli_num_rows($sqlc) > 0) {
echo "this sku already exists in this category";
} else {
echo "1";
}
}
function addSubCategory($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['subcategoryname']);
$url = strtolower(str_replace(" ", "-", $name));
$categoryID = $_POST['categoryid'];
$sortorder = mysqli_real_escape_string($conn, $_POST['txtsortorder']);
$title = mysqli_real_escape_string($conn, $_POST['txttitle']);
$keyword = mysqli_real_escape_string($conn, $_POST['txtkeyword']);
$decription = mysqli_real_escape_string($conn, $_POST['txtdecription']);
if (isset($_POST['status'])) {
$status = 1;
} else {
$status = 0;
}
$sqlc = mysqli_query($conn, "select * from tbl_sub_category where url='$url' and category_id='$categoryID'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "this category already exists in this category";
} else {
$sql = "insert into tbl_sub_category(name,category_id,url,visibility_status,sort_order,meta_title,meta_keyword,meta_description) values('$name','$categoryID','$url','$status','$sortorder','$title','$keyword','$decription')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo '1';
} else {
echo "Record has not been added.";
}
}
}
function editSubCategory($conn)
{
$id = $_POST['txtsubcateoryid'];
$name = mysqli_real_escape_string($conn, $_POST['subcategoryname']);
$url = strtolower(str_replace(" ", "-", $name));
$categoryID = $_POST['categoryid'];
$sortorder = mysqli_real_escape_string($conn, $_POST['txtsortorder']);
$title = mysqli_real_escape_string($conn, $_POST['txttitle']);
$keyword = mysqli_real_escape_string($conn, $_POST['txtkeyword']);
$decription = mysqli_real_escape_string($conn, $_POST['txtdecription']);
if (isset($_POST['status'])) {
$status = 1;
} else {
$status = 0;
}
$sqlc = mysqli_query($conn, "select * from tbl_sub_category where url='$url' and category_id='$categoryID' and id!='$id'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "this category already exists in this category";
} else {
$sqladd = mysqli_query($conn, "update tbl_sub_category set
name='$name',
url='$url',
category_id='$categoryID',
visibility_status='$status',
sort_order='$sortorder',
meta_title='$title',
meta_keyword='$keyword',
meta_description='$decription' where id = '$id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
//$sql="insert into tbl_filter(name,category_id,status ) values('$filtername','$categoyid','$v')";
//if(mysqli_query($conn,$sql) or die(mysqli_error($conn)))
///{
echo "2";
} else {
echo "Record has not been updated.";
}
}
}
function deleteSubCategory($conn)
{
$id = isset($_POST['subcategoryid']) ? $_POST['subcategoryid'] : "";
$sqlc = mysqli_query($conn, "select * from tbl_item where sub_category_id='$id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "This sub category record content other record ";
} else {
//-------------------------------------------------------------------------------------------------
//echo "value is ".$id;
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from tbl_sub_category where id = '$id' ";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
mysqli_query($conn, "COMMIT");
echo "1";
} else {
mysqli_query($conn, "ROLLBACK");
echo "Record has not been deleted";
}
//-------------------------------------------------------------------------------------------------
}
}
function addSwitchSubCategory($conn)
{
$id = $_POST['txtsubcateoryid'];
$categoryID = $_POST['categoryid'];
$oldCategoryID = $_POST['oldcategoryid'];
$sqladd = mysqli_query($conn, "update tbl_sub_category set
category_id='$categoryID' where id = '$id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
/*-------------------*/
$sqlcheck = mysqli_query($conn, "select * from tbl_item where category_id = '$oldCategoryID' and sub_category_id='$id'") or die(mysqli_error($conn));
if (mysqli_num_rows($sqlcheck) > 0) {
$sqladd = mysqli_query($conn, "update tbl_item set
category_id='$categoryID' where category_id = '$oldCategoryID' and sub_category_id='$id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
echo "1";
} else {
echo "Record has not been updated.";
}
} else {
echo "1";
}
/*-------------------*/
} else {
echo "Record has not been updated.";
}
}
function addFilter($conn)
{
$categoyid = $_POST['txtcategoyid'];
$filtername = mysqli_real_escape_string($conn, $_POST['txtfiltername']);
if (isset($_POST['chkvisible'])) {
$v = 1;
} else {
$v = 0;
}
if (isset($_POST['chkmultiple'])) {
$m = 1;
} else {
$m = 0;
}
if (isset($_POST['chkvalidation'])) {
$vl = 1;
} else {
$vl = 0;
}
$sqlc = mysqli_query($conn, "select * from tbl_filter where name='$filtername' and category_id='$categoyid'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "this filter already exists in this category";
} else {
$sql = "insert into tbl_filter(name,category_id,status,multiple,validation ) values('$filtername','$categoyid','$v','$m','$vl')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "1";
} else {
echo "Record has not been added.";
}
}
}
function editFilter($conn)
{
$id = $_POST['txtfilterid'];
$categoyid = $_POST['txtcategoyid'];
$filtername = mysqli_real_escape_string($conn, $_POST['txtfiltername']);
if (isset($_POST['chkvisible'])) {
$v = 1;
} else {
$v = 0;
}
if (isset($_POST['chkmultiple'])) {
$m = 1;
} else {
$m = 0;
}
if (isset($_POST['chkvalidation'])) {
$vl = 1;
} else {
$vl = 0;
}
$sqlc = mysqli_query($conn, "select * from tbl_filter where name='$filtername' and category_id='$categoyid' and id!='$id'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "this filter already exists in this category";
} else {
$sqladd = mysqli_query($conn, "update tbl_filter set
name='$filtername',
category_id='$categoyid',
status='$v',
multiple='$m',
validation='$vl' where id = '$id'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
//$sql="insert into tbl_filter(name,category_id,status ) values('$filtername','$categoyid','$v')";
//if(mysqli_query($conn,$sql) or die(mysqli_error($conn)))
///{
echo "2";
} else {
echo "Record has not been updated.";
}
}
}
function showSubCategory($conn)
{
$category = $_POST['category'];
showSubCategoryTable($conn, $category);
}
function showSubCategoryTable($conn, $category)
{
$sqlc = mysqli_query($conn, "select * from tbl_sub_category where category_id='$category' order by id desc") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
/*-----------------------------------*/
echo 'S.No Name Sort Order Visible Control ';
$i = 1;
while ($rows = mysqli_fetch_assoc($sqlc)) {
extract($rows);
if ($visibility_status == 1) {
$v = "visible";
} else {
$v = "Invisible";
}
echo "" . $i++ . " " . "" . $name . " " . "" . $sort_order . " " . $v . " Edit
Delete ";
}
echo '
';
/*-----------------------------------*/
} else {
echo "no record";
}
}
function searchShowFilterTable($conn)
{
$category = $_POST['category'];
$search = $_POST['search'];
$sqlc = mysqli_query($conn, "select * from tbl_sub_category where name like '%$search%' and category_id='$category' ") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
/*-----------------------------------*/
echo 'S.No Name Sort Order Visible Control ';
$i = 1;
while ($rows = mysqli_fetch_assoc($sqlc)) {
extract($rows);
if ($visibility_status == 1) {
$v = "visible";
} else {
$v = "Invisible";
}
echo "" . $i++ . " " . "" . $name . " " . "" . $sort_order . " " . $v . " Edit
Delete ";
}
echo '
';
/*-----------------------------------*/
} else {
echo "no record";
}
}
function deleteFilter($conn)
{
$id = isset($_POST['filterID']) ? $_POST['filterID'] : "";
//echo "value is ".$id;
$sql = mysqli_query($conn, "START TRANSACTION");
$del = "delete from tbl_filter where id = '$id' ";
if (mysqli_query($conn, $del) or die(mysqli_error($conn))) {
mysqli_query($conn, "COMMIT");
echo "1";
} else {
mysqli_query($conn, "ROLLBACK");
echo "Record has not been deleted";
}
}
function addProduct($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['productcategoryname']);
$sql = "insert into tbl_category(name,department_id ) values('$name',1)";
if (mysqli_query($conn, $sql) or die(mysql_error($conn))) {
$sqls = mysqli_query($conn, "SELECT * FROM tbl_category order by id desc limit 1") or die(mysqli_error($conn));
$rows = mysqli_fetch_assoc($sqls);
echo $rows['id'] . "," . $rows['name'];
} else {
echo "1";
}
}
function addFilterValue($conn)
{
$type = mysqli_real_escape_string($conn, $_POST['txtfitertype']);
$fiterid = mysqli_real_escape_string($conn, $_POST['txtfiterid']);
$filtervalue = mysqli_real_escape_string($conn, $_POST['txtfiltervalue']);
$sqlc = mysqli_query($conn, "select * from tbl_filter_value where filter_id='$fiterid' and filter_value='$filtervalue'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "2";
} else {
$sql = "insert into tbl_filter_value(filter_id , filter_value) values('$fiterid' , '$filtervalue')";
if (mysqli_query($conn, $sql) or die(mysql_error($conn))) {
$sqls = mysqli_query($conn, "SELECT * FROM tbl_filter_value order by id desc limit 1") or die(mysqli_error($conn));
$rows = mysqli_fetch_assoc($sqls);
if ($type == 0) {
echo $rows['id'] . "," . $rows['filter_value'];
} else {
echo ' ' . $rows['filter_value'] . ' ';
}
} else {
echo "1";
}
}
}
function addBTOB($conn)
{
$name = $_POST['name'];
$sqlc = mysqli_query($conn, "select * from tbl_b2b where name='$name'") or die(mysqli_query($conn));
if (mysqli_num_rows($sqlc) > 0) {
echo "2";
} else {
$sql = "insert into tbl_b2b(name) values('$name')";
if (mysqli_query($conn, $sql) or die(mysql_error($conn))) {
$sqls = mysqli_query($conn, "SELECT * FROM tbl_b2b order by id desc limit 1") or die(mysqli_error($conn));
$rows = mysqli_fetch_assoc($sqls);
echo ' ' . $rows['name'] . ' ';
} else {
echo "1";
}
}
}
function matrialName($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['matrialname']);
$sql = "insert into tbl_matrial(name) values('$name')";
if (mysqli_query($conn, $sql) or die(mysql_error($conn))) {
$sqls = mysqli_query($conn, "SELECT * FROM tbl_matrial order by id desc limit 1") or die(mysqli_error($conn));
$rows = mysqli_fetch_assoc($sqls);
echo $rows['id'] . "," . $rows['name'];
} else {
echo "1";
}
}
function soleName($conn)
{
$name = mysqli_real_escape_string($conn, $_POST['solename']);
$sql = "insert into tbl_sole(name) values('$name')";
if (mysqli_query($conn, $sql) or die(mysql_error($conn))) {
$sqls = mysqli_query($conn, "SELECT * FROM tbl_sole order by id desc limit 1") or die(mysqli_error($conn));
$rows = mysqli_fetch_assoc($sqls);
echo $rows['id'] . "," . $rows['name'];
} else {
echo "1";
}
}
function personCategoryName()
{
$url = $_POST['url'];
$selnews = mysql_query("select * from tbl_person_category where url = '$url' ") or die(mysql_error());
if (mysql_num_rows($selnews) > 0) {
echo "0";
} else {
echo "1";
}
}
function fieldCategoryName()
{
$url = $_POST['url'];
$selnews = mysql_query("select * from tbl_field_category where url = '$url' ") or die(mysql_error());
if (mysql_num_rows($selnews) > 0) {
echo "0";
} else {
echo "1";
}
}
function brandCategoryName()
{
$url = $_POST['url'];
$selnews = mysql_query("select * from tbl_field_category where url = '$url' ") or die(mysql_error());
if (mysql_num_rows($selnews) > 0) {
echo "0";
} else {
echo "1";
}
}
function productName()
{
$url = $_POST['url'];
$selnews = mysql_query("select * from tbl_product where url = '$url' ") or die(mysql_error());
if (mysql_num_rows($selnews) > 0) {
echo "0";
} else {
echo "1";
}
}
function getProductCategoryList($conn)
{
$departmentID = $_POST['departmentID'];
?>
Select
0) {
//------------------------------------------
$sql = "insert into tbl_dipatch(order_id ,dispatched_through, tracking ,date_of_dipatch) values('$orderid','$dispatchedthrough','$tracking','$dateofdispatch')";
if (mysqli_query($conn, $sql) or die(mysqli_error($conn))) {
echo "1";
} else {
echo "0";
}
//---------------------------------------------
} else {
echo "0";
}
}
function updatestatus($conn)
{
$orderid = $_POST['orderid'];
$orderstatus = $_POST['selorderstatus'];
$sqladd = mysqli_query($conn, "update tbl_order set order_status='$orderstatus' where order_id = '$orderid'") or die(mysqli_error($conn));
if (mysqli_affected_rows($conn) > 0) {
//------------------------------------------
echo "1";
//---------------------------------------------
} else {
echo "0";
}
}
function sendSMS($phone, $message)
{
$api2 = "https://eadwinetech.com/smsgate/services/send.php?key=82db18198e40e70941371d133c1fbf16c9d84b95&number=%2B91" . $phone . "&message=" . $message . "&devices=23|0&type=sms&prioritize=1";
$response2 = file_get_contents($api2);
//echo $response2;
}
function sendEmail($email, $messagebody)
{
$to = $email;
$subject = 'Reset password';
$message = $messagebody;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: I write what you feel ' . "\r\n";
// Mail it
$flgSend = @mail($to, $subject, $message, $headers);
}
function getUID()
{
$time = "";
$time .= date('y');
$time .= date('m');
$time .= date('d');
$time .= date('h');
$time .= date('i');
$time .= date('s');
$time .= rand(10, 99);
return $time;
}
function sendRegisterMail($conn, $email)
{
$name = $_POST['name'];
$to = $email;
$subject = "Welcome to Sukhalya";
$message = '
Namaste ' . $name . ' ,
Welcome to Sukhalya Family!
Your account has been successfully created and We are more than happy to see you at Sukhalya.
All your physical & mental fitness needs are taken care of at sukhalya. You may visit our ongoing Workshops, Courses, Products & Retreats at sukhalya.com
If you have any Doubt/Queries - you may whatsapp us at 8630998989 or mail us at namaste@sukhalya.com
We are very excited to practice with you! 🧘♂
Hope to see you soon!
Warm Regards,
Sukhalya Team
Explore Sukhalya
© 2023 , All Rights Reserved Sukhalya
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Sukhalya ' . "\r\n";
// Mail it
$flgSend = @mail($to, $subject, $message, $headers);
}
?>