Пример #1
0
error_reporting(0);
include 'Connector.php';
$db = new Connector();
function notificacion($msj)
{
    echo "<script>\n            alert('" . $msj . "');\n        </script>";
}
if (isset($_POST['btn_acceder'])) {
    $correo = $db->sec($_POST['correo']);
    $contrasena = $db->sec($_POST['contrasena']);
    if ($correo == null || $contrasena == null) {
        notificacion($msj = "Por favor complete todos los campos");
        header("Location:/loginPHP");
    } else {
        $consulta = "SELECT * FROM usuarios WHERE correo_usuario = '" . $correo . "' AND password_usuario = '" . $contrasena . "';";
        $db->execute($consulta);
        if ($result->num_rows == 1) {
            while ($resultado = $result->fetch_assoc()) {
                session_start();
                $_SESSION["Nombre"] = $resultado['nombre_usuario'];
                $_SESSION["Id"] = $resultado['id_usuario'];
                session_write_close();
            }
            header("Location:/loginPHP/Bienvenido.php");
        } else {
            notificacion($msj = "El usuario o contraseña son incorrectos, vuelve a intentar.");
            header("Location:/loginPHP");
        }
    }
}
Пример #2
0
<?php

require_once "classes/db.php";
if (!empty($_POST)) {
    $object = $_POST['object'];
    $value = $_POST['value'];
    $type = $_POST['type'];
    $speed = $_POST['speed'];
    $al = $_POST['al'];
    $db = new Connector();
    if (strcmp($al, "asset") == 0) {
        $db->query("insert into assets(object, value, type, speed) values (:object, :value, :type, :speed)");
        $db->bind(":object", $object);
        $db->bind(":value", $value);
        $db->bind(":type", $type);
        $db->bind(":speed", $speed);
        $db->execute();
    } else {
        if (strcmp($al, "liability") == 0) {
            $db->query("insert into liabilities(object, value, type, speed) values (:object, :value, :type, :speed)");
            $db->bind(":object", $object);
            $db->bind(":value", $value);
            $db->bind(":type", $type);
            $db->bind(":speed", $speed);
            $db->execute();
        }
    }
}
header("Location: ../");