<?
session_start();
session_unset();
session_destroy();
session_register('estado');
session_register('usuario');
session_register('pass');
session_register('empresa');
session_register('empresa_global');
if (!isset($_POST["usuario1"]))
{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 

		exit();
}
?>

<form id="form1" name="form1" method="post" action="index_clientes.php" target="_parent">
</form>
<?
$user=$_POST["usuario1"];
$clave=$_POST["pass1"];
$claveen = md5($clave);
include("conex.php");
$sql_log = "SELECT * FROM nombres WHERE rut = '$user' AND rut = '$clave'";
$res_log = mysql_query($sql_log, $enlace);

if (mysql_fetch_object($res_log))
	{
	$id_user = mysql_result($res_log, 0, "rut");
	$id_segmento = mysql_result($res_log, 0, "id_segmento");
	$id_empresa =1;	

	$_SESSION['estado'] = "ON";
	$_SESSION['usuario'] = "$user";
	$_SESSION['pass'] = "$claveen";
	$_SESSION['ss_empresa'] = "$id_empresa";
	$_SESSION['empresa_global'] = $id_empresa;
	$_SESSION['ss_user'] ="$id_user";
	
	?>
	<script language="javascript">
	
	parent.location.href = 'index_clientes.php';
	</script>
    <?
    
	}
else
	{
	?>
	<script language="javascript">
	alert ("Cliente no existe");
	parent.location.href = 'index.php';
	</script>
	<?	
	}
?>


