PHP & Cookies
Publicado por Manuel (1 intervención) el 16/11/2005 18:27:57
Estoy aprendiendo y me he quedado atascado con las galletitas. A ver si alguien me hecha una mano. Tengo el siguiente código:
<?php
setcookie("toma_galleta",$nombre,time()+86400);
?>
<html>
<body>
<form action="index.php" method="POST">
<br>
Nombre:
<br>
<input type="text" name="nombre">
<br>
<input type="submit" value="Enviar">
</form>
<br><br><br>
Hola!
<?
if (isset ($_COOKIE["toma_galleta"]) )
{
echo $_COOKIE["toma_galleta"];
}
else
{
echo " invitado";
}
?>
</body>
</html>
Y al ejecutarlo me da el siguiente error:
Notice: Undefined variable: nombre in c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php:1) in c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php on line 2
Tengo el easy php. Muchas gracias.
<?php
setcookie("toma_galleta",$nombre,time()+86400);
?>
<html>
<body>
<form action="index.php" method="POST">
<br>
Nombre:
<br>
<input type="text" name="nombre">
<br>
<input type="submit" value="Enviar">
</form>
<br><br><br>
Hola!
<?
if (isset ($_COOKIE["toma_galleta"]) )
{
echo $_COOKIE["toma_galleta"];
}
else
{
echo " invitado";
}
?>
</body>
</html>
Y al ejecutarlo me da el siguiente error:
Notice: Undefined variable: nombre in c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php:1) in c:\archivos de programa\easyphp1-8\www\pruebas\cookies\index.php on line 2
Tengo el easy php. Muchas gracias.
Valora esta pregunta


0