<?php session_start();
// $codigo = $_POST["Identi"]  ;
// $alias  = $_POST["Alias"]   ;
// $movil  = $_POST["Celular"] ;
// $placa  = $_POST["Placa"]   ;

include_once('lib_main.php');
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 

$dom = new DOMDocument();
     $dom->encoding = 'utf-8';
     $dom->xmlVersion = '1.0';
     $dom->formatOutput = true;

$response=$dom->appendChild($dom->createElement("response"));
// $msgsys=$response->appendChild($dom->createElement("msgsys",$sql_query)); 
$msgswal=$response->appendChild($dom->createElement("msgswal")); 
     $msgswal->setAttribute("id","msgswal");

if(empty($codigo))
     {
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text","Identificación de Chofer en Blanco ")); 
     }
elseif(empty($descri))
     {    
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text",'Nombre de Chofer en Blanco')); 
     }
elseif(empty($celular))
     {
//           $msgalert=$response->appendChild($dom->createElement("msgalert",'Clave INCORRECTA'));
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text",'Numero de Celular en Blanco')); 
     }
elseif(empty($placa))
     {
//           $msgalert=$response->appendChild($dom->createElement("msgalert",'Clave INCORRECTA'));
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text",'Numero de Placa en Blanco')); 
     }
else
     {
//           $msgalert=$response->appendChild($dom->createElement("msgalert",'Acceso OK'));     
          $msgswal->appendChild($dom->createElement("icon","success")); 
          $msgswal->appendChild($dom->createElement("title","Acceso OK")); 
          $msgswal->appendChild($dom->createElement("text","Grabando Chofer")); 
          $result=$response->appendChild($dom->createElement("result",""));
               $result->appendChild($dom->createElement("enti_codigo",$codigo));
               $result->appendChild($dom->createElement("enti_descri",$descri));
               $result->appendChild($dom->createElement("enti_celular",$celular));
//          $user0=data_maes('user',$user_codigo);
//          foreach($user0 as $key=>$value)
//          {$_SESSION[$key]=$value;}
//          $_SESSION['user_token']=$user_token;
     }

echo $dom->saveXML();

// // echo '*/*/*/*/*';
// echo '<response>';
// $empr = 'demo' ;
// $link_data=msql_connect('','','',$empr);
// $lcSql = "Select * from enti0 where enti_codigo = '".$codigo."'";
// //echo '<msgalert>'."Estoy Grabando... ".'</msgalert>' ;
// $row_cont =msql_query($lcSql,$link_data);
// if (msql_num_rows($row_cont) == 0)
//     $lcSql='INSERT INTO enti0(enti_codigo, enti_contacto, enti_celular) VALUES("'.$codigo.'","'.$alias.'","'.$movil.'")';
// else
//     $lcSql='UPDATE enti0 SET enti_contacto ="'.$alias.'", enti_celular ="'.$movil.'" WHERE enti_codigo = "'.$codigo.'"';
// $resultado=msql_query($lcSql,$link_data);
// echo '<msgalert>'.'*/*/*/*'.$lcSql.'</msgalert>';
// $error = mysqli_error($link_data) ;
// // sif(!empty($error))
// {echo '<msgsys>'.' ERROR:'.$error.' \n '.'SQL : '.$lcSql.'</msgsys>';}

// echo '</response>';

?>