<?php

require "gestordb.php";
//conectar a la base de datos si hay datos en el formulario
$conexion = new gestordb("root", "admin", "Daw");
$conexion->connect_to_db();
//comprobar que user y password tengan valores
if (isset($_POST["user"]) && isset($_POST["password"])) {
    //validar los datos en la base de datos
    if ($conexion->autenticar($_POST["user"], $_POST["password"])) {
        session_start();
        //inicia la sesion en el navegador
        $_SESSION["autentificado"] = "si";
        //genera un indice-valor dentro del array de la sesion
        header("Location:aplication.php");
        //crea un head en el aplication.php
    } else {
        header("Location:index.php?errorusuario=si");
    }
}
Beispiel #2
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tarea 21</title>
</head>

<body>
	<?php 
//comprueba que el formulario contenga datos en todos los campos
//e inserta la información en la base de datos. Seguidamente fuerza el flujo
//hacia form.php
if (isset($_POST["lugar"]) && isset($_POST["poblacion"]) && isset($_POST["nota"])) {
    $db = new gestordb("localhost", "root", "admin", "Daw");
    $db->connect_to_db();
    echo $db->getInfo();
    $db->addRow($_POST["lugar"], $_POST["poblacion"], $_POST["nota"]);
}
?>

	<div id="form" style="font-family:Verdana, Geneva, sans-serif; text-transform:capitalize">
    	<form method="post" action="index.php">
        	Lugar <input type="text" name="lugar"/><br/>
			Población <input type="text" name="poblacion"/><br/>
            Nota <input type="number" name=		"nota" /><br/><br/>
            <input type="submit" name="Enviar"/>                    
        </form>
    </div>
</body>
</html>
Beispiel #3
0
<?php

require_once "gestordb.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

	
<body>
<?php 
$gestor = new gestordb("localhost", "root", "admin", "Daw");
$gestor->connect_to_db();
$gestor->addRow("Puerta del Sol", "Madrid", "9");
echo $gestor->getInfo();
echo "</br>";
echo $gestor->getLugares();
?>
</body>
</html>