ok bien lo primero decir que es un proyecto mvc y estoy ussando un motor de plantillas que es el smarty por lo que tengo 2 login el del codigo php y el del html
login.tpl.php:
Código HTML:
<html>
<head>
<title>{$smarty.const.APP_NAME}</title>
</head>
<body>
<h2>{$smarty.const.APP_NAME}</h2>
{if $error_msg}
{$error_msg}
{/if}
<form action="login.php" method="post">
usuario: <input type="text" name="username"/><br>
password: <input type="password" name="password"/><br>
<input type="submit" name="validar" value="login"/>
</form>
</body>
</html>
login.php
Código PHP:
<?php
require_once 'conf.php';
try {
if (isset($_POST['validar'])){
try{
$usuarioDAO=UsuarioDAOFactory::getInstancia();
$usuario=$usuarioDAO->login($_POST['username'],$_POST['password']);
$_SESSION['usuario']=$usuario;
header('location: index.php');
exit (0);
}catch(UsuarioValidacionExcepcion $e){
$smarty->assign('error_msg',$e->getMessage());
}
}
$smarty->display('login.tpl.php');
}catch(Exception $e){
$smarty->assign('error',$e->getMessage());
$smarty->display('error.tpl.php');
}
?>
y este usa el archivo conf.php
Código PHP:
<?php
//configuracion
define("APP_NAME","Mantenimiento de Usuarios");
define("APP_BASEDIR",dirname(__FILE__));
ini_set('session.gc_maxlifetime','1800');//30min
ini_set('error_reporting','E_ALL');
//Smarty
require_once APP_BASEDIR.'/clases/util/Plantilla.class.php';
$smarty=new Plantilla();
//Base de Datos
define('DB_SERVER','localhost');
define('DB_SERVER_USERNAME','root');
define('DB_SERVER_PASSWORD','root');
define('DB_DATABASE','usuario');
//construyendo la clase principal
require_once APP_BASEDIR.'/clases/dao/UsuarioDAOFactory.class.php';
$usuarioDAO= UsuarioDAOFactory::getInstancia();
//iniciando las sesion
session_start();
?>
asta ahi todo ok en index esta la tabla que muestra la base de datos de usuarios y tiene un boton guardar y eliminar y ayerm e di cuenta q al usarlos tambien me muestra arriba en mensajes lo que hago y en serio es molesto , todo funciona bien pero esos mensajes nunca me habian aparecido
Aqui esta mi index :
Código HTML:
<html>
<head>
<title>{$smarty.const.APP_NAME}</title>
</head>
<body>
<h2>{$smarty.const.APP_NAME}</h2>
<h3>Bienvenido {$smarty.session.usuario->nombres}
{$smarty.session.usuario->paterno}
{$smarty.session.usuario->materno}
</h3>
<form action="guardar.php" method="post">
<table>
<tr>
<td><label>Nombres</label></td>
<td><input type="text" name="nombres" value="{$usuario->nombres}"></td>
<td><label>Paterno</label></td>
<td><input type="text" name="paterno" value="{$usuario->paterno}"></td>
<td><label>Materno</label></td>
<td><input type="text" name="materno" value="{$usuario->materno}"></td>
</tr>
<tr>
<td><label>Email</label></td>
<td><input type="text" name="correo" value="{$usuario->correo}"></td>
<td><label>Direccion</label></td>
<td><input type="text" name="direccion" value="{$usuario->direccion}"></td>
<td><label>Telefono</label></td>
<td><input type="text" name="telefono" value="{$usuario->telefono}"></td>
</tr>
<tr>
<td colspan="6">
<input type="hidden" name="idusuario" value="{$usuario->idusuario}">
<input type="submit" value="Guardar" name="guardar">
</td>
</tr>
</table>
</form>
<form action="index.php" method="post">
<table>
<tr>
<td><label>Nombres</label></td>
<td><input type="text" name="nombres" value="{$nombres}"></td>
<td><input type="submit" name="buscar" value="Buscar"></td>
</tr>
</table>
</form>
<form action="eliminar.php" method="post">
<table border="1">
<tr>
<th>Idusuario</th>
<th>Nombres</th>
<th>Paterno</th>
<th>Materno</th>
<th>Correo</th>
<th>Direccion</th>
<th>Telefono</th>
<th>Eliminar</th>
</tr>
{foreach from = $lista item=usuario}
<tr>
<td>{$usuario->idusuario}</td>
<td>{$usuario->nombres}</td>
<td>{$usuario->paterno}</td>
<td>{$usuario->materno}</td>
<td>{$usuario->correo}</td>
<td>{$usuario->direccion}</td>
<td>{$usuario->telefono}</td>
<td colspan="6">
<input type="checkbox" name="idusuario" value="{$usuario->idusuario}">
<input type="submit" value="Eliminar" name="eliminar">
</td>
</tr>
{/foreach}
</table>
</form>
<br><a href="logout.php">Salir</a>
</body>
</html>