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


    $snof_update= intval (isset($_REQUEST['snof_update']) ? (is_null($_REQUEST['snof_update'])? '0':$_REQUEST['snof_update']) : '0');
    $mail_siv= isset($_REQUEST['mail_siv_update']) ?(is_null($_REQUEST['mail_siv_update'])? '':$_REQUEST['mail_siv_update']) : '';
    $myfile = fopen("logFileMail.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 mail_establecimientos_rojo set mail_siv='$mail_siv' where snof   = '$snof_update' ";
    @mysqli_query( $conn,$sqlv);  	
    mysqli_query( $conn,"COMMIT");
    $result["msg"] = $mensaje;
    echo json_encode($result);

} catch(exception $error) {
    
mysqli_query( $conn,"ROLLBACK");
$result["msg"] = "Errores grabando en la base de datos: ".$error->getMessage();
echo json_encode($result);
}
    
    $myfile = fopen("logFileMail.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); 
  
?>

