<?php

require 'cn.php';
$tel_id= $_POST["tel_id"];
$tel_user= $_POST["tel_user"];
$tel_sucursal= $_POST["tel_sucursal"];
$tel_area= $_POST["tel_area"];
//$sucursal= $_POST['cbx_ubicacion'];
$tel_equipo= $_POST["tel_equipo"];
$tel_imei= $_POST["tel_imei"];
$tel_num= $_POST["tel_num"];
$tel_sim= $_POST["tel_sim"];
$tel_costo= $_POST["tel_costo"];
$tel_acce= $_POST["tel_acce"];




//Consulta para insertar
$insertar="INSERT INTO v_phone2(tel_id, tel_user, tel_sucursal, tel_area, tel_equipo, tel_imei, tel_num, tel_sim, tel_costo, tel_acce) VALUES ('$tel_id','$tel_user', '$tel_sucursal','$tel_area','$tel_equipo','$tel_imei','$tel_num','$tel_sim','$tel_costo','$tel_acce')";


$verificar_imei =mysqli_query($conexion, "SELECT * FROM v_phone2 WHERE tel_imei='$tel_imei'");
if(mysqli_num_rows($verificar_serie)>0){
	echo '<script>
		alert("El numero de IMEI ya esta Registrado");
		window.history.go(-1);
		</script>';
	exit;
}


//Ejecutar consulta
$resultado= mysqli_query($conexion, $insertar);

?>

<html lang="es">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link  href="css/bootstrap-theme.css" rel="stylesheet">
	<script src="js/jquery-3.1.1.min.js"></script>
	<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="row" style="text-align: center">
				<?php if($resultado){ ?>
					<h3>REGISTRO GUARDADO</h3>
				<?php } else { ?>
					<h3>ERROR AL REGISTRAR</h3>
					<?php } ?>
				<a href="cel.php" class="btn btn-primary">REGRESAR</a>
			</div>
		</div>
	</div>
</body>
</html>