<?php 
include('functions.php');

if (isset($_REQUEST['nomusu'])){$nomusu=$_REQUEST['nomusu'];}else{$nomusu="";}
if (isset($_REQUEST['api'])){$api=$_REQUEST['api'];}else{$api="";}
if (isset($_REQUEST['peremp'])){$pass=$_REQUEST['peremp'];}else{$peremp="";}
if (isset($_REQUEST['accion'])){$accion=$_REQUEST['accion'];}else{$accion="";}
if (isset($_REQUEST['nomper'])){$nomper=$_REQUEST['nomper'];}else{$nomper="";}
if (isset($_REQUEST['nriper'])){$nriper=$_REQUEST['nriper'];}else{$nriper="";}
if (isset($_REQUEST['telper'])){$telper=$_REQUEST['telper'];}else{$telper="";}




date_default_timezone_set('America/Bogota');
$time = time();
$fechamod=date("d-m-Y (H:i:s)", $time);
$accionres=0;//0 nada; 1 encontrado; 2 registrado con exito; 3 error
$Mpassusu="";
$Mnomusu="";
 
	$Sqlactids="select * from usrweb  where nomusu='".$nomusu."' ";
	$resultset=getSQLResultSet($Sqlactids);
	if($resultset){
		while ($row = $resultset->fetch_array(MYSQLI_ASSOC)){
	      	$accionres=1;
			$Mpassusu=$row['conusu'];
			$Mnomusu=$row['nomusu'];
		}
	}


if($accionres==0 and $accion=="ADD" ){
 $query="insert into usrweb( ";
		$query=$query."nomusu,conusu,peremp,";
		$query=$query."nomper,nriper,telper";
		$query=$query.") ";
		$query=$query."values(";
		$query=$query."'".$nomusu."','".$api."','".$peremp."',";
		$query=$query."'".$nomper."','".$nriper."','".$telper."'";
		$query=$query.")";
		$permiso=ejecutarSQLCommand($query);
		
		
	$accionres=3;
        $Sqlactids="select * from usrweb  where nomusu='".$nomusu."' ";
	$resultset=getSQLResultSet($Sqlactids);
	if($resultset){
		while ($row = $resultset->fetch_array(MYSQLI_ASSOC)){
	      	$accionres=2;
		}
	}
	
}
if($accionres==1 and $accion=="REC" ){//Recordar Pass
    $Sqlactids="select * from usrweb  where nomusu='".$nomusu."' ";
	$resultset=getSQLResultSet($Sqlactids);
	if($resultset){
		while ($row = $resultset->fetch_array(MYSQLI_ASSOC)){
	      	$accionres=$row['nomusu'];
		}
	}
}

echo $accionres;
?>      

