<?php
     $result = array();
    include '../comunes_php/cors.php';
    $mensaje = "Fueron guardados sus datos";
    include '../rdb/conn.php';


    $cli_update= intval (isset($_REQUEST['cli_update']) ? (is_null($_REQUEST['cli_update'])? '0':$_REQUEST['cli_update']) : '0');
    $mail_cli_update= isset($_REQUEST['mail_cli_update']) ?(is_null($_REQUEST['mail_cli_update'])? '':$_REQUEST['mail_cli_update']) : '';
    $myfile = fopen("logFileMailCli.txt", "a") or die("Unable to open file!");
    $parametros = print_r($_POST,TRUE);
    
    fwrite($myfile, "-----------------------------------------------------------------------------------------------------");
    
    fwrite($myfile, $parametros );
    
    fwrite($myfile, $sqlv);
    fclose($myfile); 
    

   
  
try {    
mysqli_query( $conn,"SET AUTOCOMMIT=0");
mysqli_query( $conn,"START TRANSACTION");

    $sqlv  = "update clientes set email='$mail_cli_update' where id  = $cli_update ";
    @mysqli_query( $conn,$sqlv);  	
    mysqli_query( $conn,"COMMIT");
    $result["msg"] = $mensaje;
    $result["success"] = true;
    echo json_encode($result);
    


} catch(exception $error) {
    
mysqli_query( $conn,"ROLLBACK");
$result["msg"] = "Errores grabando en la base de datos: ".$error->getMessage();
$result["success"] = false;

echo json_encode($result);
}
    
    $myfile = fopen("logFileMailCli.txt", "a") or die("Unable to open file!");
    $parametros = print_r($_POST,TRUE);
    fwrite($myfile, "<br>");
   
    fwrite($myfile, "-----------------------------------------------------------------------------------------------------");
    
    fwrite($myfile,$result["msg"]);
    fwrite($myfile, "<br>");

    fwrite($myfile, $sqlv);
    fclose($myfile); 
  
?>