Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/05/2003, 02:01
Nemor
 
Fecha de Ingreso: junio-2002
Mensajes: 45
Antigüedad: 21 años, 10 meses
Puntos: 0
creacion cookie

hola ojala me puedan ayudar he tenido problemas para crear la cookie para la session, no se donde este el error, ya que unas paginas me marcan un erro de header
ejemplo
he aqui los codigos.

uregistrar.php
<?
include("config.php") ;
if($registrar) {
function quitar($texto) {
$texto = trim($texto) ;
$texto = str_replace("<","&lt;",$texto) ;
$texto = str_replace(">","&gt;",$texto) ;
return $texto ;
}
$nick = quitar($nick) ;
$contrasena = quitar($contrasena) ;
$email = quitar($email) ;
mysql_query("insert into usuarios (nick,contrasena,email) values ('$nick','$contrasena','$email')") ;
echo "Has sido registrado con éxito. Haz click <a href=index.php>aquí</a> para ir a la página principal." ;
}
else {
?>
<p>Los datos marcados con un asterisco (*) son obligatorios.
<form name="formulario" method="post" action="uregistrar.php">
<b>* Nick:</b><br>
<input type="text" name="nick" maxlength="20"><br>
<b>* Contraseña:</b><br>
<input type="password" name="contrasena" maxlength="20"><br>
<b>* Email:</b><br>
<input type="text" name="email" maxlength="40"><br><br>
<input type="submit" name="registrar" value="Registrar">
</form>
<?
}
mysql_close($conectar) ;
?>

uentrar.php
<?
include("config.php") ;
if($entrar) {
function quitar($texto) {
$texto = trim($texto) ;
$texto = str_replace("<","&lt;",$texto) ;
$texto = str_replace(">","&gt;",$texto) ;
return $texto ;
}
$nick = quitar($nick) ;
$contrasena = quitar($contrasena) ;
$resp = mysql_query("select contrasena from usuarios where nick='$nick'") ;
$datos = mysql_fetch_array($resp) ;
if(mysql_num_rows($resp) != 0) {
if($datos[contrasena] != $contrasena) {
echo "La contraseña es incorrecta. Haz click <a href=javascript:history.back()>aquí</a> para regresar." ;
}
else {
setcookie("unick",$nick,time()+7776000) ;
header("location: rotador.php") ;
}
}
else {
echo "Este usuario no existe en la base de datos." ;
}
}
else {
echo "
<form method=post action=uentrar.php>
<b>Nick:</b><br>
<input type=text name=nick maxlength=20><br>
<b>Contraseña:</b><br>
<input type=password name=contrasena maxlength=20><br><br>
<input type=submit name=entrar value=Entrar>
</form>
" ;
}
?>

ulogin.php
<?
include("config.php") ;
$usuario = $_COOKIE["unick"] ;
$resp = mysql_query("select nick from usuarios where nick='$usuario'") ;
if(mysql_num_rows($resp) == 0) {
?>
<script>location='usalir.php'</script>
<?
}
mysql_free_result($resp) ;
mysql_close($conectar) ;
?>

usalir.php
<?
setcookie("unick","") ;
header("location: rotador.php") ;
?>

he estado leyendo para ver como lo puedo resolver, pero no he encontrado nada. de antemano gracias