
PK 
<?php
include "conn.php";
if($_GET['action']=='GenerateOtp'){
$arr['success'] = false;
$data="";
$q = "SELECT * from members where mobile='".$_GET['mobile']."' ";
$q = mysqli_query($GLOBALS['conn'], $q) or die(mysqli_error($GLOBALS['conn'] ));
if ($r = mysqli_fetch_array($q)) {
$arr['success'] = SendOTP($_GET['mobile'], $r['email_id']);
}else{
$q = "INSERT into members set mobile='".$_GET['mobile']."' ";
mysqli_query($GLOBALS['conn'], $q) or die(mysqli_error($GLOBALS['conn'] ));
$arr['success'] = SendOTP($_GET['mobile']);
}
// header('Content-Type: application/json; charset=utf-8');
echo json_encode($arr);
}
if($_GET['action']=="GenerateOtpNEW11111"){
$mobile = mysqli_real_escape_string($conn, $_GET['mobile']);
// Check if mobile exists in database
$query = "SELECT * FROM members WHERE mobile = '$mobile'";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
// Generate 6 digit OTP
$otp = rand(100000, 999999);
// Store OTP in database with timestamp
$timestamp = date('Y-m-d H:i:s');
$update = "UPDATE members SET otp = '$otp', otp_timestamp = '$timestamp' WHERE mobile = '$mobile'";
mysqli_query($conn, $update);
// Send OTP via SMS
// Include your SMS sending code here using your SMS gateway
// For example: sendSMS($mobile, "Your OTP is: " . $otp);
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'message' => 'Mobile number not registered']);
}
exit;
}
if($_GET['action']=='AddWishList'){
check_login();
$arr['success'] = false;
$data="";
if($_SESSION['member_id']){
$q = "SELECT * from wishlist where product_id='".$_GET['pid']."' and member_id='".$_SESSION['member_id']."' ";
$q = mysqli_query($GLOBALS['conn'], $q) or die(mysqli_error($GLOBALS['conn'] ));
if ($r = mysqli_fetch_array($q)) {
$arr['success'] = true;
$arr['msg'] = "Item already added in wishlist";
}else{
$q = "INSERT into wishlist set product_id='".$_GET['pid']."', member_id='".$_SESSION['member_id']."' ";
mysqli_query($GLOBALS['conn'], $q) or die(mysqli_error($GLOBALS['conn'] ));
$arr['success'] = true;
$arr['msg'] = "Item Successfully added in wishlist";
}
}else{
$arr['success'] = true;
$arr['msg'] = "Please login to add wishlist";
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($arr);
}


PK 99