¿como muestro error sin redirigir?
Publicado por giuli (74 intervenciones) el 06/08/2015 18:28:06
Tengo el form de login en la portada:
Como veran coloque un parrafo:
con la variable error pero no aparece nada.
Pero en la barra del navegador si se ve el mendaje o parametro(en la url)
aqui log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="gencyolcu" />
<?php include("log.php")?>
<title>Nombre del colegio</title>
</head>
<head>
<body>
<form action="login/log.php" method="Post">
<div id="pagina">
<div id="cabecera" style="background-color: darkred; width=100%;">
<img alt="Escuela" src="http://www.casildaya.com/imagenes/despacioescuela.jpg" height="150" width="150"/>
<h1 style=" color: white; text-align: center; vertical-align: central;">NOMBRE DEL COLEGIO </h1>
<!-- Aquí vendría el código de la cabecera --></div>
<div id="cuerpo">
<div id="ColumnaIzq" style="width: 20%; float: left; height: 50%;">
<ul style="font-size: x-large; font-family: fantasy;">
<li style="cursor: pointer;">Establecimiento</li>
<li style="cursor: pointer;">Inscripciones</li>
<li style="cursor: pointer;">Plantel educativo</li>
<li style="cursor: pointer;">Contacto</li>
</ul><!-- Aquí vendría el código del menú --></div>
<div id="ColumnaCentro" style="float: next; width: 50%; height: 50%;"></div>
<!-- <p>Aqui va la informacion a mostrar</p>-->
<div id="ColumnaDer" style="float: right; width: 30%; height: 50%;" >
<form method="get" action="file:///E:/xampp/htdocs/Tesis/Admin.php">
<p><strong>Login</strong></p>
<p>Usuario</p><input type="text" name="user" style="font-size: x-large;"/>
<p>Contraseña</p><input type="password" name="pass" style="font-size: x-large;" />
<p><?php echo $error;?></p>
<button type="submit" name="Ingresar" style="background:transparent border:none"><img src="img/entrarboton.gif" width="90" height="50" /></button>
</form>
</div>
</div>
<div id="footer" style=" clear: both; background-color: darkred; width=100%;">
<p style="color: white;"><strong>Datos del colegio: </strong><br />
Telefono: 0000-000000<br />
Direccion: dhjfksfu 4568<br />
Correo: aaa@hfjds.com</p><!-- Aquí vendría el código del pié --></div>
</div>
</body>
</html>
Como veran coloque un parrafo:
1
<p><?php echo $error;?></p>
Pero en la barra del navegador si se ve el mendaje o parametro(en la url)
aqui log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
include("../includes/php/conexion.php");
$con=conectar();
$usuario = htmlentities(trim($_POST['user']));
$contraseña=htmlentities(trim($_POST['pass']));
$queryuser="select idlogin from login where usuario='".mysql_escape_string($usuario)."';" or die( "Error en " . mysql_error() );
$querypass="select contraseña from login where usuario='".mysql_escape_string($usuario)."';";
$buscaruser=mysqli_query($con,$queryuser);
$existe=mysqli_num_rows($buscaruser);
$uservalido=mysqli_query($con,$querypass);
$row=mysqli_fetch_assoc($uservalido);
$queryper="select idpersona from persona where idlogin='$row[idlogin]'";
$error="";
if (isset ($_POST['Ingresar'])){
if(isset($usuario) && isset($contraseña)){
if ($existe>0){
if ($row['contraseña']==$contraseña){
session_start();
$_SESSION['usuarioRegistrado'] = true;
$_SESSION['username'] = $username;
header('location: ../panel.php');
}
else{
$error="Error: Contraseña incorrecta";
header('Location: ../PagPrincipal.php?'.$error);
}
}
else{
$error="Error: Usuario no encontrado";
header('Location: '.$_SERVER['HTTP_REFERER']);
}
}
}
?>
Valora esta pregunta


0