$result = mysql_query("SELECT * FROM Clientes WHERE login='".$HTTP_COOKIE_VARS["usNick"]."' AND pass='".$HTTP_COOKIE_VARS["usPass"]."'");
y loguea bien y todo pero soy incapaz de que me muestre los datos...Os pongo los 3 archivos a ver si veis algo mal..
Este es el formulario donde ingresan el login y password y se loguean.
Código:
por POST le paso a ingresar.php ese login y pass<form action="ingresar.php" method="post"> <label for="login">Login</label><input type="text" class="Estilo6bis" name="login" id="login" /> <br /> <label for="pass">Password</label><input type="password" class="Estilo6" name="pass" id="pass" /> <p> <input class="clase2" type="submit" name="Submit" value="Aceptar" /> </p>
Código PHP:
<?php
include("conectarse_bd.php");
//$link=Conectarse();
function quitar($mensaje)
{
$mensaje = str_replace("<","<",$mensaje);
$mensaje = str_replace(">",">",$mensaje);
$mensaje = str_replace("\'","'",$mensaje);
$mensaje = str_replace('\"',""",$mensaje);
$mensaje = str_replace("\\\\","\",$mensaje);
return $mensaje;
}
if(trim($HTTP_POST_VARS["login"]) != "" && trim($HTTP_POST_VARS["pass"]) != "")
{
/*Asi que continuamos suponiendo que todo este bien, ahora lo que hacemos es quitarle el html,
apostrofe comillas y demas al nick y password enviados por el usuario para su comprobacion
con la base de datos, para ello utilizamos la funcion quitar($mensaje) que explicamos antes,
y guardamos las nuevas cadenas en dos nuevas variables:*/
$nickN = quitar($HTTP_POST_VARS["login"]);
$passN = quitar($HTTP_POST_VARS["pass"]);
/*Ahora ejecutamos una instruccion sql, en la cual le pedimos a la base de da
tos que de la tabla usuarios nos devuelva la fila cuyo nick corresponda por
el enviado por el usuario: */
$result = mysql_query("SELECT pass FROM Clientes WHERE login='$nickN'");
if($row = mysql_fetch_array($result))
{
/*Ahora continuamos con el proceso suponiendo que el usuario exista en la base de datos ahora
debemos comprobar que el password sea correcto, para ello hacemos una simple comparacion, si
es correcto continuamos de lo contrario mostramos el mensaje de password incorrecto: */
if($row["pass"] == $passN)
{
session_start();
$_SESSION['caduca'] = time() + 7776000;
$_SESSION['usNick'] = $nickN;
$_SESSION['usPass'] = $passN;
//la pabtalla principal cuando ya te has logeado correctamente
header("Location: cuenta.php");
}
else
{
header("Location: error_clientes.php");
}
}
else
{
header("Location: error_clientes.php");
}
mysql_free_result($result);
}
else
{
header("Location: error_clientes.php");
}
mysql_close();
?>
Código PHP:
<?php
include("conectarse_bd.php");
include("login.php");
$result = mysql_query("SELECT * FROM Clientes WHERE login='".$HTTP_COOKIE_VARS["usNick"]."' AND pass='".$HTTP_COOKIE_VARS["usPass"]."'");
while($row = mysql_fetch_array($result)) {
}
if($loginCorrecto)
{
//echo "<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold; float:right;' > Bienvenido Administrador $nickUsuarioL </p>";
$mostrar = "Bienvenido !!!!";
}
else
{
//echo "Bienvenido visitante, el sistema no te ha reconocido, sino te autentificas no podras realizar ninguna de las funciones";
$mostrar = 'Bienvenido visitante, el sistema no te ha reconocido, sino te autentificas no podras realizar ninguna de las funciones';
//falla
header("Location: acceso.html");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nogues | Arquitecto</title>
<script type="text/javascript" src="Funciones.js"></script>
<link rel="stylesheet" type="text/css" href="Estilo.css"/>
</head>
<body>
<div id="Contenedor">
<div id="Capa_titulo_admin">
<div id="logo" onclick="location='index.html'" title="Inicio" ></div>
</div>
<div id="Capa_admin">
<?php echo "<p style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold; float:right;' > Zona Clientes </p>";
printf("<tr><td><td> %s</td><td><td> %s </td><td> </tr>", $row["nombre"],$row["apellido1"], $row["apellido2"]);
?>
<form id="form1" method="post" action="">
<fieldset class="clase1"><legend>Datos Personales</legend>
<label for="nombre">Nombre</label><input name="nombre" type="text" id="nombre" value= "<?php $row["nombre"];?>" size="40" readonly="readonly"/>
<br />
<label for="apellidom">Apellido </label><input name="apellido1" type="text" id="apellido1" value= "<?php echo $row["apellido1"];?>" size="40" readonly="readonly"/>
<br />
<label for="apellidop">Apellido </label><input name="apellido2" type="text" id="apellido2" value= "<?php echo $row["apellido2"];?>" size="40" readonly="readonly" />
<br />
<label for="Email">Email</label>
<input name="mail" type="text" id="mail" value= "<?php echo $row["mail"];?>" size="40" readonly="readonly"/>
<br />
<label for="telefono">Telefono</label><input name="telefono" type="text" id="telefono" value= "<?php echo $row["telefono"];?>" size="40" readonly="readonly" />
<br />
<label for="direccion">Dirección</label><input name="direccion" type="text" id="direccion" value= "<?php echo $row["direccion"];?>" size="40" readonly="readonly" />
<br />
</fieldset>
<fieldset class="clase1"><legend>Trabajos en curso</legend>
<?php
$sql="SELECT * FROM Expedientes WHERE dni='$dniUsuarioL'";
$link = "<a href=\"cuenta2.php?expediente=%s\">%s<br></a>";
$result = mysql_query($sql);
if(isset($result) && mysql_num_rows($result)>0)
{
while($fila=mysql_fetch_assoc($result))
{
echo sprintf( $link, $fila['expediente'], $fila['nombre'] );
echo "<br>";
}
}
?>
</fieldset>
</form>
<?
//si hay resultados crea tabla
if ($row = mysql_fetch_array($result)){
echo "<table border = '1'> \n";
//Mostramos los nombres de las tablas
mysql_field_seek($result,0);
echo "<tr> \n";
echo "<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Fecha</b></td> \n";
echo "<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Nombre</b></td> \n";
echo "<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Ver</b></td> \n";
echo "<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Eliminar</b></td> \n";
echo "<td style='font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; font-weight: bold;' <b>Modificar</b></td> \n";
echo " </tr> \n";
echo "</tr> \n";
do {
echo "<tr> \n"; //para ver el cliente entero
?><form name="form1" method="post" action="datos_expedientes.php">
<?
echo "<td>"?>
<textarea cols="22" rows="1" name="fecha" readonly style="overflow:auto; border-width: 2px; font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; text-align:center;"><?php echo $row["fecha"];?></textarea>
</TD>
<? "</td> \n";
echo "<td>"?>
<textarea cols="70" rows="1" name="nombre" readonly style="overflow:auto; border-width: 2px; font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; text-align:center;"><?php echo $row["nombre"];?></textarea>
<? "</td> \n";
?>
<?
echo "<td>"?>
<input type="submit" name="Submit" value="Ver detalles" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; text-align:center;"></TD>
</form>
<? echo "<td>"?>
<form name="form" method="post" action="confirmacion_baja_exp.php">
<input name="expediente" type="hidden" value="<? echo $row["expediente"]; ?>">
<input type="submit" name="Submit2" value="Eliminar" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; text-align:center;"></TD>
</form>
<? echo "<td>"?>
<form name="form" method="post" action="modificar_expediente.php">
<input name="expediente" type="hidden" value="<? echo $row["expediente"]; ?>">
<input type="submit" name="Submit2" value="Modificar" style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;color: #000000; text-align:center;"></TD>
</form>
<?
"</td> \n"; ?>
<?
echo "</tr> \n";
} while ($row = mysql_fetch_array($result));
}
?>
</table>
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><a href="cerrar_sesion.php">Cerrar sesión</a> </p>
</div>
</div>
</body>
</html>