<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$array    = '';
$zdb = $_SESSION["zdbyear_".$dbname];
mysqli_select_db($conn,$zdb);

if(isset($_REQUEST['mobile'])){
   $mmobile = $_REQUEST['mobile'];
//   print "SELECT a.*, b.discount FROM `item` a, `itemgrp` b WHERE a.barcode = '$barcoden' and a.group = b.code " ;
   $iresult = mysqli_query($conn,"SELECT `mobile2`, `name`, `lastname`,`tel`,`tel2`,`email`,`city` FROM `leadenq` WHERE mobile ='$mmobile' order  by vouchno desc limit 0,1") or die(mysqli_error($conn));
   //$iresult = mysqli_query($conn,"SELECT * FROM `item` WHERE name = '$itemn' ") or die(mysqli_error($conn));
   if(mysqli_num_rows($iresult) > 0){
      $array    = mysqli_fetch_array($iresult);
      
      $mobile2      = $array["mobile2"];
      $name         = $array["name"];
      $lastname     = $array["lastname"];
      $tel          = $array["tel"];
      $tel2         = $array["tel2"];
      $email        = $array["email"];
      $city         = $array["city"];
    } 
    
    header("Content-type: application\json");
    $data=array("mobile2"=>$mobile2,"name"=>$name,"lastname"=>$lastname,"tel"=>$tel,"tel2"=>$tel2,"email"=>$email,"city"=>$city);
    echo json_encode($data);
}

?>