Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/08/2008, 14:58
yowmy
 
Fecha de Ingreso: enero-2008
Mensajes: 62
Antigüedad: 16 años, 3 meses
Puntos: 0
ayuda con sesion de usuarios en php

hola tengo el siguiente codigo pero no me funciona si alguien sabe cual es el error me lo hacen saber,



-----------------------------------
template.php
------------------------------------
<?php
include ("auth.inc.php");
?>
<html>
<head>
<title>Beginning PHP, Apache, MySQL Web Development</title>
</head>
<body>
<h1>This is the Template Page</h1>
</body>
</html>



-----------------------
auth.inc.php
-----------------------

<?php
session_start();
if ($_SESSION[‘logged’] != 1)
{
$redirect = $_SERVER[‘PHP_SELF’];
header(“Refresh: 5; URL=login.php?redirect=$redirect”);
echo “You are being redirected to the login page!<br>”;
echo “(If your browser doesn’t support this, <a
href=\”login.php?redirect=$redirect\”>click here</a>)”;
die();
}
?>



-----------------------
login.php
-----------------------


<?php
session_start();
$_SESSION[‘logged’] = 0;
if (isset($_POST[‘submit’]))
{
if ($_POST[‘username’] == “wroxbooks” && $_POST[‘password’] == “aregreat”)
{
$_SESSION[‘logged’] = 1;
header (“Refresh: 5; URL=” . $_POST[‘redirect’] . “”);
echo “You are being redirected to your original page request!<br>”;
echo “(If your browser doesn’t support this, <a href=\”” .
$_POST[‘redirect’]. “\”>click here</a>)”;
}
else
{
?>
<html>
<head>
<title>Beginning PHP, Apache, MySQL Web Development</title>
</head>
<body>
Invalid Username and/or Password<br><br>
<form action=”login.php” method=”post”>
<input type=”hidden” name=”redirect” value=”<?php echo $_POST[‘redirect’];
?>”>
Username: <input type=”text” name=”username”><br>
Password: <input type=”password” name=”password”><br><br>
<input type=”submit” name=”submit” value=”Login”>
</form>
<?php
}
}
else
{
?>
<html>
<head>
<title>Beginning PHP, Apache, MySQL Web Development</title>
</head>
<body>
You must be logged in to view this page<br><br>
<form action=”login.php” method=”post”>
<input type=”hidden” name=”redirect” value=”<?php echo $_GET[‘redirect’]; ?>”>
Username: <input type=”text” name=”username”><br>
Password: <input type=”password” name=”password”><br><br>
<input type=”submit” name=”submit” value=”Login”>
</form>
<?php
323
Using Logins, Profiles, and Personalization
}
?>
</body>
</html>



-----------------------------------------


estos tres codigos se fucionan para trabajar el problema es que cuando ejecuto template.php deberia de funcionar y me da el siguiente error: "error unexpected ´:´ in (127.0.0.1/demo/do/auth.inc.php linea 6), yo no entiedo por que si el codigo esta bien, estoy usando wamp 5.1, si alguien sabe el error o si alguien sabe otra manera de hacer un sistema de login me lo hacen saber.


Gracias!