示例#1
0
function saldo()
{
    $respuesta;
    try {
        $dbh = conectarbase();
        /*** echo a message saying we have connected ***/
        //echo 'Connected to database';
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "SELECT saldo FROM cliente join usuario on(idusuario=usuario_idusuario)  WHERE usuario='" . $_SESSION['usuario'] . "'";
        /*** prepare the SQL statement ***/
        $stmt = $dbh->prepare($sql);
        /*** execute the prepared statement ***/
        $stmt->execute();
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        /*** close the database connection ***/
        $dbh = null;
        return $result['saldo'];
    } catch (PDOException $e) {
        //echo $e->getMessage();
        $exito = false;
    }
    return NULL;
}
示例#2
0
 public function horario()
 {
     $respuesta;
     try {
         $dbh = conectarbase();
         /*** echo a message saying we have connected ***/
         //echo 'Connected to database';
         $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $sql = "SELECT inicio,fin,fecha,costo,nombre FROM horario,espacio  WHERE idespacio=espacio_idespacio and idhorario='" . $this->idhorario . "'";
         /*** prepare the SQL statement ***/
         $stmt = $dbh->prepare(sql);
         /*** execute the prepared statement ***/
         $stmt->execute();
         $result = $stmt->fetch(PDO::FETCH_ASSOC);
         /*** close the database connection ***/
         $dbh = null;
         return $result;
     } catch (PDOException $e) {
         //echo $e->getMessage();
         $exito = false;
     }
     return NULL;
 }
示例#3
0
function buscar($usuario, $contra)
{
    try {
        $dbh = conectarbase();
        /*** echo a message saying we have connected ***/
        //echo 'Connected to database';
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        /*** prepare the SQL statement ***/
        $stmt = $dbh->prepare("SELECT * from usuario where usuario=:usuario");
        $stmt->bindParam(':usuario', $usuario, PDO::PARAM_STR, 10);
        /*** execute the prepared statement ***/
        $stmt->execute();
        $result = $stmt->fetchAll();
        $existe = false;
        /*** loop of the results ***/
        foreach ($result as $row) {
            if (strcmp($row['usuario'], $usuario) == 0) {
                if (validate_password($contra, $row['contrasena'])) {
                    $existe = true;
                    $resultado = $existe;
                    break;
                }
            }
        }
        /*** close the database connection ***/
        $dbh = null;
    } catch (PDOException $e) {
        //echo $e->getMessage();
        $exito = false;
    }
    return $resultado;
}
示例#4
0
	<?php 
include_once 'conn.php';
session_start();
$tr = "";
try {
    $dbh = conectarbase();
    /*** echo a message saying we have connected ***/
    //echo 'Connected to database';
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "SELECT cliente.nombre as nombre, horario.fecha as fecha, inicio, fin, espacio.nombre as espacio  \n\t\t\t        FROM usuario join cliente on(idusuario=usuario_idusuario) join factura \n\t\t\t        on(idcliente=cliente_idcliente) join reserva on(idfactura=factura_idfactura) join horario \n\t\t\t        on(idhorario=horario_idhorario) join espacio on(idespacio=espacio_idespacio) \n\t\t\t        WHERE usuario=:usuario";
    /*** prepare the SQL statement ***/
    $usu = trim($_SESSION['usuario']);
    $stmt = $dbh->prepare($sql);
    $stmt->bindParam(':usuario', $usu, PDO::PARAM_STR, 30);
    /*** execute the prepared statement ***/
    $stmt->execute();
    $result = $stmt->fetchAll();
    /*** close the database connection ***/
    $dbh = null;
    foreach ($result as $row) {
        $hinicio = strtotime($row['inicio']);
        $hinicio = date("h:i:00 a", $hinicio);
        $hfin = strtotime($row['fin']);
        $hfin = date("h:i:00 a", $hfin);
        $tr .= "<tr><td>" . $row['nombre'] . "</td><td>" . $row['fecha'] . "</td><td>" . $hinicio . "</td><td>" . $hfin . "</td><td>" . $row['espacio'] . "</td></tr>";
    }
} catch (PDOException $e) {
    echo $e->getMessage();
    $exito = false;
}
?>
示例#5
0
function agregar()
{
    $pass = $_POST['contrasena1'];
    $pass = create_hash($pass);
    //echo $password;
    try {
        $dbh = conectarbase();
        // new PDO("mysql:host=" . $hostname . ";dbname=cssreservation", $username, $password);
        /*** echo a message saying we have connected ***/
        //echo 'Connected to database';
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        /*** prepare the SQL statement ***/
        $stmt = $dbh->prepare("INSERT into usuario (usuario,contrasena,correo,tipo) values (:usuario,:contrasena,:correo,:tipo) ");
        $stmt->bindParam(':usuario', $_POST['usuario'], PDO::PARAM_STR, 10);
        $stmt->bindParam(':contrasena', $pass, PDO::PARAM_STR, 32);
        $stmt->bindParam(':correo', $_POST['email'], PDO::PARAM_STR, 32);
        $stmt->bindParam(':tipo', $_POST['tipo'], PDO::PARAM_INT);
        /*** execute the prepared statement ***/
        $stmt->execute();
        if (isset($_POST['DUI'])) {
            if ($_POST['DUI'] != "") {
                $fecha = date("Y-m-d");
                $stmt = $dbh->prepare("INSERT into cliente (nombre, apellido, DUI, telefono, direccion, fecha_nac, NIT, fecha_mem,usuario_idusuario, saldo, total) values (:nombre, :apellido, :dui, :tel, :adress, :fechanac, :nit, :fechamem,(select idusuario from usuario where usuario=:usuario), 100, 100) ");
                $stmt->bindParam(':nombre', $_POST['nombre'], PDO::PARAM_STR, 50);
                $stmt->bindParam(':apellido', $_POST['apellido'], PDO::PARAM_STR, 50);
                $stmt->bindParam(':dui', $_POST['DUI'], PDO::PARAM_STR, 10);
                $stmt->bindParam(':tel', $_POST['telefono'], PDO::PARAM_STR, 9);
                $stmt->bindParam(':adress', $_POST['direccion'], PDO::PARAM_STR, 100);
                $stmt->bindParam(':fechanac', $_POST['fecha_nac'], PDO::PARAM_STR, 10);
                $stmt->bindParam(':nit', $_POST['NIT'], PDO::PARAM_STR, 17);
                $stmt->bindParam(':fechamem', $fecha, PDO::PARAM_STR, 15);
                $stmt->bindParam(':usuario', $_POST['usuario'], PDO::PARAM_STR, 15);
                $stmt->execute();
            }
        }
        $exito = true;
        /*** close the database connection ***/
        $dbh = null;
    } catch (PDOException $e) {
        echo $e->getMessage();
        $exito = false;
    }
    return $exito;
}