Tengo problemas al redirigir...
Tengo un formulario con login y password y un link que permitiria entrar como invitado en el sistema:
Código:
Luego en el codigo de comprueba los datos y los busca en la BD:<form action="login.php" method="post" onSubmit="return validarLogin(this);"> <table align = "center" width="50%" border="0" cellspacing="2" cellpadding="2" bgcolor="#98FB98"> <tr> <td colspan="2" align="center" <? if ($_GET["err"]=="nouser"){?> bgcolor=red> <span style="color:ffffff"><font size="2"> Usuari no existeix!</font></span><br> <? }else if ($_GET["err"]=="pass"){?> bgcolor=red> <span style="color:ffffff"><font size="2"> Contrasenya incorrecta!</font></span><br> <? }else {?> bgcolor=#32cd32> <font size="2">Introdueix les dades </font> <? } ?></td> </tr> <tr> <td>Número de lector: </td> <td><input name="numLector" type="text"></td> </tr> <tr> <td>Contrasenya</td> <td><input name="pass" type="password"></td> </tr> <tr> <td colspan="2" align="center"><input name="submit" type="Submit" value="Iniciar Sessió"></td> </tr> <tr> <td colspan="2" align="center"><a href="login.php?usuari=convidat">Entrar com a convidat</a></td> </tr> <tr> <td colspan="2" align="center">adios</td> </tr> </table> </form>
Código PHP:
<body>
<?
include "includes/connexio.php";
$db=conectarse();
$numLector=$_POST['numLector'];
$psw=md5($_POST['pass']);
$usuari=$_GET['usuari'];
if ($usuari=="convidat"){
header("Location: /guest.php");
}else{
$cons="SELECT * FROM lectors WHERE NumLector = '$numLector'";
$result=mysql_query($cons,$db);
if (mysql_num_rows($result)==0){
header("Location: /index.php?err=nouser");
}else{
$fila=mysql_fetch_array($result);
if ($fila['Password']!=$psw){
header("Location: /index.php?err=pass");
}else{
switch ($fila['Perfil']){
//session_start();
case "Estudiant": echo "estudiantes"; break;
/*$_SESSION["Perfil"]="Estudiant";
header("Location: /aplicacionNormal.php");*/
case "Professor/a": echo "professor"; break;
/*$_SESSION["Perfil"]="Professor";
header("Location: /aplicacionProfesor.php");*/
}
}
}
}
?>
</body>
Gracias, por adelantado.