tomassantos
To fold or to FOLD?
.
Última edição:
<?php
session_start();
// A password que pretendes
$password='12345';
// O url para onde queres redireccionar depois do login
$url='http://tomasalmeidasantos.freehostia.com/encomendas.html';
$autenticado=$_SESSION['autenticado'];
if($autenticado==1){
header('Location:'.$url,TRUE,301);
exit();
}
else {
if($_POST['password']==$password){
$_SESSION['autenticado']=1;
header('Location:'.$url,TRUE,301);
}
elseif(isset($_POST['password']) && $_POST['password']!=$password) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
font-family: Georgia, Tahoma, Verdana, Arial;
font-size: 13px;
}
.erro {
color: #F00;
}
</style>
<title>Login</title>
</head>
<body>
<span class="erro">Password inválida</span><br />
<form method="POST" action="login.php">
<label for="password">Password:</label><input type="password" name="password" id="password" />
<input type="submit" value="Submeter" />
</body>
</html>';
}
else {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
font-family: Tahoma, Verdana, Arial;
font-size: 13px;
}
</style>
<title>Login</title>
</head>
<body>
Têm de autenticar-se.<br />
<form method="POST" action="login.php">
<label for="password">Password:</label><input type="password" name="password" id="password" />
<input type="submit" value="Submeter" />
</body>
</html>';
}
}
?>
<?php
session_start();
$_SESSION['autenticado']=0;
// O url para onde queres redireccionar depois de fazer o logout
$url='http://tomasalmeidasantos.freehostia.com/login.php';
header('Location:'.$url,TRUE,301);
exit();
?>
<?php
session_start();
// O url para onde queres redireccionar caso não tenha password
$url='http://tomasalmeidasantos.freehostia.com/login.php';
$autenticado=$_SESSION['autenticado'];
if($autenticado==1){
// O código da tua página
}
else {
header('Location:'.$url,TRUE,301);
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
font-family: Tahoma, Verdana, Arial;
font-size: 13px;
}
</style>
<title>Encomendas</title><body bgcolor="#B5B591" text="#336600" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0">
</head>
<body>
Digite a sua senha para acessar<br />
<form method="POST" action="login.php">
<label for="password">Password:</label><input type="password" name="password" id="password" />
<input type="submit" value="Submeter" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
background: #B5B591;
color: #336600;
font-family: Tahoma, Verdana, Arial;
font-size: 13px;
}
</style>
<title>Login</title>
</head>
<body>
Digite a sua senha para acessar<br />
<form method="POST" action="login.php">
<label for="password">Password:</label><input type="password" name="password" id="password" />
<input type="submit" value="Submeter" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
background: #B5B591;
color: #336600;
font-family: Tahoma, Verdana, Arial;
font-size: 13px;
}
</style>
<title>Login</title>
</head>
<body>
O teu texto ou conteúdo....
</body>
</html>
<?php
session_start();
// O url para onde queres redireccionar caso não tenha password
$url='login.php';
$autenticado=$_SESSION['autenticado'];
if($autenticado==1){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="content-language" content="pt" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="robots" content="noindex, nofollow" />
<style>
body {
background: #B5B591;
color: #336600;
font-family: Tahoma, Verdana, Arial;
font-size: 13px;
}
</style>
<title>Login</title>
</head>
<body>
<p align="left"> </p>
<p align="left"> </p>
<a href="logout.php"><font color="#008000" size="4">Terminar Sessão</font></a>
</body>
</html>
<?php
}
else {
header('Location:'.$url,TRUE,301);
exit();
}
?>
Não era suposto ficar assim:
Código:<?php session_start(); // O url para onde queres redireccionar caso não tenha password $url='login.php'; $autenticado=$_SESSION['autenticado']; if($autenticado==1){ // O código da tua página <body bgcolor="#B5B591" text="#336600" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="content-language" content="pt" /> <meta http-equiv="imagetoolbar" content="false" /> <meta name="robots" content="noindex, nofollow" /> <style> body { background: #B5B591; color: #336600; font-family: Tahoma, Verdana, Arial; font-size: 13px; } </style> <title>Login</title> </head> <body> </body> </html></p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> </p> <p align="left"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <a href="logout.php"><font color="#008000" size="4">Terminar Sessão</font></a></p> </p> </body> </html> } else { header('Location:'.$url,TRUE,301); exit(); } ?>
Diz que dá erro na linha 11 (onde começa o que disseste)
O que tá mal?
Obrigado p+ela ajuda.
Obrigado pela sugestão, mas isso só me iria dar trabalho
Mas eu 'não quero' aprender PHP...
Até porque não estou a pedir uma coisa muito complexa...acho eu.
Calma, eu só quero uma ajudinha para meter as mensagens no sitio que quero. Este fórum é para ajudar...