Page 1 of 1

PHP and cookies

Posted: Fri Jan 31, 2003 10:42 am
by Paul knapp
Hi all

I wonder if any one can help me?

I'm trying to write a php form using cookies, so when the user enters his/her details in the form the next time they return the info is there.....

I cracked this using one <input type="text" name="name"> box.

But the problem is I want 2 input boxes not one. And I cant seem to get it to work. this is the next input box I want to go in there:

<input type="text" name="address">

Any help would be very much appreciated

Below is a sample of the code I have done so far:

====================================

<?php

if ($myCookie=="")

{

setcookie("myCookie",$name, time() + 60*60*24*365*10);

?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="name">
<input type="submit" value="submit">
</form>
<?php

}

else

{

setcookie("myCookie",$var, time() + 60*60*24*365*10);

?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="name" value="<?=$myCookie?>">
<input type="submit" value="submit">
</form>
<?php

}

?>

Posted: Sun Feb 02, 2003 12:52 am
by Oleg Butuzov
:lol:

isset()

$_COOKIE['name']


now you can change your script yourself...

Posted: Sun Feb 02, 2003 1:44 am
by Paul knapp
Could you please help me on this I am very new to php and I would not know where to place that function.

Thanks mate :)

Posted: Sun Feb 02, 2003 1:49 am
by Oleg Butuzov
If you are New. read documentation.

statment

is (!isset($_COOKIE['cookiename']))
{


}

Posted: Sun Feb 02, 2003 5:35 am
by Paul knapp
Well thank you so much for your help....

You was as much use as a bull in a china shop!