<?php 
session_start();
if ($_SESSION['login']!=true) {header("Location: ../salidausuario.php");}
require_once('../utilesphp/sql_oop.php'); //conexion a base de datos
$q=$mysqli->query('SELECT * FROM clientes WHERE rut="'.$_GET['rut'].'"');
$rq = $q->fetch_array();
if ($q->num_rows==0) {
	if (isset($_GET['rut']) AND isset($_GET['razon']) AND isset($_GET['direccion']) AND isset($_GET['ciudad'])){
		$insert=$mysqli->query('INSERT INTO clientes (rut,razon,direccion,ciudad,giro,contacto,mail,telefono1,telefono2,limitecredito) VALUES ("'.$_GET['rut'].'","'.$_GET['razon'].'","'.$_GET['direccion'].'","'.$_GET['ciudad'].'","'.$_GET['giro'].'","'.$_GET['contacto'].'","'.$_GET['mail'].'","'.$_GET['telefono1'].'","'.$_GET['telefono2'].'","'.$_GET['limitecredito'].'")');
	}
}
if ($q) {
	$q->free();
}
$mysqli->close();
header('Location: ../tablas-clientes.php');
?>