<?php

require_once 'config.php';
//$error=false;
$errors=array();

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
	
   
   
	$query = "SELECT * FROM users WHERE id='".$_GET['user_id']."'";
	
	
    $row = mysqli_query($con,$query);
     
    if (mysqli_num_rows($row) >= 1) { 
		$r=mysqli_fetch_array($row);
			
			$errors['user_id'] = $r['id'];
			$errors['username'] = $r['username'];
			$errors['first_name'] = $r['first_name'];
			$errors['last_name'] = $r['last_name'];
			$errors['email'] = $r['email'];
			$errors['phone'] = $r['phone'];
			$errors['profile_pic'] = $r['profile_pic'];
			$errors['address'] = $r['address'];
			$errors['pincode'] = $r['pincode'];
			$errors['floor'] = $r['floor'];
			$errors['unit_no'] = $r['unit_no'];
			
			$errors['city'] = $r['city'];
			$country_id = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM `countries` where id=".$r['country_id']));
			$errors['country'] =$country_id['name'];
			
			$errors['category'] = $r['category'];
			
			$errors['credits']=$r['credits'];
			$errors['vouchers']=$r['vouchers'];
			$errors['points']=$r['point_wallet'];
			
		
		$errors['success']='User Profile';
    } else {
        //$error=true;
		$errors['success']='No data found !!';
    }
	echo json_encode($errors);
  
}

?>