'.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}else{
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].''.$user['country'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}
$country = $user['country'];
$state = $user['state'];
$user_id = $user['user_id'];
}
if($_REQUEST['opt_out'] == 'searchbox'){
$search = $_REQUEST['search_box'];
$get_add = mysqli_query($conn, "SELECT * FROM shop_user where phone = '$search[0]' and dealer_id = '$dealer_id'");
$check_rows = mysqli_num_rows($get_add);
if($check_rows == 0){
echo '
This phone number '.$search[0].' is not available go back and search a new one.
';
exit;
}else{
$user = mysqli_fetch_assoc($get_add);
if($user['country'] == 'India'){
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}else{
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].''.$user['country'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}
$country = $user['country'];
$state = $user['state'];
$user_id = $user['user_id'];
}
}
if($_REQUEST['opt_out'] == 'add_address'){
$date=date('Y-m-d H:i:s');
$dealer = $_REQUEST['dealer'];
$mobile_no = $_REQUEST['mobile_no'];
$addr = $_REQUEST['addr'];
$city = $_REQUEST['city'];
$country = $_REQUEST['country'];
if($country !='India'){
$state = '';
}else{
$state = $_REQUEST['state'];
}
$pin_code = $_REQUEST['pincode'];
$get_cust = mysqli_query($conn, "SELECT * FROM shop_user where phone='$mobile_no' and dealer_id = '$dealer_id'");
$check_rows_add = mysqli_num_rows($get_cust);
$insert = "INSERT INTO shop_user(`password`, `name`, `phone`, `address`, `city`, `postcode`, `country`, `state`, `date`, `gst`, `new_status`, `status`, `dealer_id`) values
('test@123','$dealer', '$mobile_no', '$addr', '$city', '$pin_code', '$country', '$state', '$date', 'GST', '0', '1', '$dealer_id')";
if($check_rows_add == 0){
if(mysqli_query($conn, $insert)){
$last = mysqli_insert_id($conn);
$user_name = 'drganbu-'.$last;
$update = "UPDATE shop_user set username='$user_name' where user_id='$last'";
mysqli_query($conn, $update);
$get_add = mysqli_query($conn, "SELECT * FROM shop_user where phone = '$mobile_no' and dealer_id = '$dealer_id'");
$user = mysqli_fetch_assoc($get_add);
if($user['country'] == 'India'){
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}else{
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].''.$user['country'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}
$country = $user['country'];
$state = $user['state'];
$user_id = $user['user_id'];
}
}else{
echo '
The phone number is already available in our system with the below address,
if you want to save a new address, please use a new phone number.
';
$get_add = mysqli_query($conn, "SELECT * FROM shop_user where phone = '$mobile_no' and dealer_id = '$dealer_id'");
$user = mysqli_fetch_assoc($get_add);
if($user['country'] == 'India'){
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}else{
$name = $user['name'].''.nl2br(strip_tags($user['address'])).''.$user['city'].''.$user['state'].''.$user['country'].' '.$user['postcode'].'Mobile: '.$user['phone'];
}
$country = $user['country'];
$state = $user['state'];
$user_id = $user['user_id'];
}
}
echo $name;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://drganbuganapathi.com/dealer/php/calc_quote_shipping_charges.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'dealer_id='.$dealer_id.'&country='.$country.'&state='.$state,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, TRUE);
?>