<?php session_start(); require_once 'conectar.php'; require_once '../negocio/cliente.php'; if (isset($_POST['usuario']) && isset($_POST['password'])) { if ($_POST['usuario'] != "" && $_POST['password'] != "") { $usuario = $_POST['usuario']; $password = $_POST['password']; $coneccion = get_conection($usuario, $password); if ($coneccion !== false) { header("Location: ../index.php"); $_SESSION['usuario'] = $usuario; $_SESSION['pass'] = $password; $_SESSION['session_begin'] = date("d/m/Y H:i"); header("Location: ../index.php"); die; } else { header("Location: ../index.php?error=" . "No se puede Conectar"); session_destroy(); die; } } } elseif (!empty($_POST['formulario']) && $_POST['formulario'] == 'nuevo') { $usuario = $_SESSION['usuario']; $password = $_SESSION['pass']; $apellido = $_POST['apellido']; $nombre = $_POST['nombre']; $edad = $_POST['edad']; //$coneccion = get_conection($usuario,$password); $estado = alta_cliente($apellido, $nombre, $edad, $usuario, $password);
function search($apellido, $nombre, $usuario, $password) { $coneccion = get_conection($usuario, $password); if ($coneccion !== false) { try { $sql = "SELECT * FROM clientes WHERE apellido like :apellido and nombre like :nombre"; // and edad = :edad"; $stmt = $coneccion->prepare($sql); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->bindParam(':apellido', $apellido); $stmt->bindParam(':nombre', $nombre); //$stmt->bindParam(':edad', $edad); $stmt->execute(); $results = $stmt->fetchAll(); return $results; } catch (PDOException $e) { return -1; } } }