Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/09/2009, 09:31
Avatar de mayid
mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
intriga con un formulario con $_SERVER['PHP_SELF']

TEngo un formulario que sirve para autenticacion de usuario. Esto, en un archivo PHP que dice asi:


Código PHP:
<?php     

if (isset($_POST['clave'])) 
        {
$clave "ok"; }
else  {
$clave "no esta ok";};

if (
$clave == "ok"
         {
$_SESSION['privada'] = "Bagus";}
else {
echo 
"</head><body>";
include (
"libreria/login.html");
echo 
"</body></html>"; die();
};

include (
'libreria/resto_del_html.php');
?>
Es decir que llama a un formulario por include si no esta seteada la clave correctamente (por POST). O llama al contenido si la clave esta ok.

Aqui esta el html completo para autentificacion. El action del formulario apunta a si mismo, y hay algo en todo esto que no funciona, porque no valida algo tan simple como una comprobacion de clave.

Código HTML:
<!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" lang="sp" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"  />	

<title>Carga de Fotos</title>
	<link href="libreria/style.css" type="text/css" rel="stylesheet" />

</head>
<body>
<div id="galeria_privada">
<form action="/subida_v7/subida.php" method="post">
		<h3>Escriba su contrase&ntilde;a</h3>
		<table>
		<tr>
		<td>
		<label>Usuario:
		<input name="usuario" type="text" value="invitado" /></label>
		<label>contrase&ntilde;a:
		<input name="clave" type="text" id="clave" /></label>
		</td>
		</tr>
		</table>
		<br/>
		<button type="button" id="ingresar" title="Para ingresar a la Galeria Privada necesitas una clave.">Ingresar</button>
</form>
</div>
</body>
</html>