Diferencia entre revisiones de «Usuario:ManuelRomero/pruebas»
De WikiEducator
| Línea 1: | Línea 1: | ||
<source lang=php> | <source lang=php> | ||
| − | < | + | <?php |
| + | require_once('./../include/DB.php'); | ||
| − | + | require_once('Smarty.class.php'); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | // Recuperamos la información de la sesión | |
| − | + | session_start(); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | // Y comprobamos que el usuario se haya autentificado, para evitar que puedan acceder directamente | |
| − | + | //a esta pagina sin pasar por el login | |
| − | + | if (!isset($_SESSION['usuario'])) | |
| − | + | die("Error - debe <a href='login.php'>identificarse</a>.<br />"); | |
| − | + | ||
| − | + | ||
| − | + | // Cargamos la librería de Smarty | |
| − | + | ||
| + | $smarty = new Smarty; | ||
| + | $smarty->template_dir = '/web/smarty/tiendaSmarty/templates/'; | ||
| + | $smarty->compile_dir = '/web/smarty/tiendaSmarty/templates_c/'; | ||
| + | $smarty->config_dir = '/web/smarty/tiendaSmarty/configs/'; | ||
| + | $smarty->cache_dir = '/web/smarty/tiendaSmarty/cache/'; | ||
| + | |||
| + | |||
| + | //De momento solo visualizamos que el usuario | ||
| + | $smarty->assign("usuario",$_SESSION['usuario']); | ||
| + | //Ahora mostramos la plantilla | ||
| + | |||
| + | $smarty->display("producto.tpl"); | ||
</source> | </source> | ||
Revisión de 13:35 11 ene 2015
<?php require_once('./../include/DB.php'); require_once('Smarty.class.php'); // Recuperamos la información de la sesión session_start(); // Y comprobamos que el usuario se haya autentificado, para evitar que puedan acceder directamente //a esta pagina sin pasar por el login if (!isset($_SESSION['usuario'])) die("Error - debe <a href='login.php'>identificarse</a>.<br />"); // Cargamos la librería de Smarty $smarty = new Smarty; $smarty->template_dir = '/web/smarty/tiendaSmarty/templates/'; $smarty->compile_dir = '/web/smarty/tiendaSmarty/templates_c/'; $smarty->config_dir = '/web/smarty/tiendaSmarty/configs/'; $smarty->cache_dir = '/web/smarty/tiendaSmarty/cache/'; //De momento solo visualizamos que el usuario $smarty->assign("usuario",$_SESSION['usuario']); //Ahora mostramos la plantilla $smarty->display("producto.tpl");