<?php
include '../admin/config.php';
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
 
	$email = $_POST["email"];   
	$pass = $_POST["pass"];
	$response["success"] = false ;

    	$query = "SELECT energe , point FROM USERS WHERE email='$email' AND pass='$pass' ";
        $result = mysqli_query($conn,$query);
         if($row = mysqli_fetch_array($result)) {
             $energe = $row['energe'] ;
			 $point = $row['point'] ;
           }else{
			 $response["success"] = "البريد الالكتروني او كلمة المرور غير صحيحة" ; 
	         echo json_encode($response); 
	         return ;
		   }
		   

   if($energe == 1 || $energe == 5 || $energe == 10 ){
	   $checkAnswer = true ;
   }
   
   
   if($checkAnswer){
       $sql = "UPDATE USERS SET energe=energe+1, log=CONCAT(log, ' DOUBLE___heart \n'), lastlogin='$Date' WHERE email='$email' ";
       $response["success"] = $conn->query($sql);
     }
   
    $conn->close();
    echo json_encode($response);

?>
	 
	 
	 
