Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

PHP and cookies

General discussions related to php

Moderators: macek, egami, gesf

PHP and cookies

Postby Paul knapp » Fri Jan 31, 2003 10:42 am

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

}

?>
Paul knapp
New php-forum User
New php-forum User
 
Posts: 6
Joined: Fri Jan 31, 2003 10:40 am

Postby Oleg Butuzov » Sun Feb 02, 2003 12:52 am

:lol:

isset()

$_COOKIE['name']


now you can change your script yourself...
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Paul knapp » Sun Feb 02, 2003 1:44 am

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 :)
Paul knapp
New php-forum User
New php-forum User
 
Posts: 6
Joined: Fri Jan 31, 2003 10:40 am

Postby Oleg Butuzov » Sun Feb 02, 2003 1:49 am

If you are New. read documentation.

statment

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


}
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Paul knapp » Sun Feb 02, 2003 5:35 am

Well thank you so much for your help....

You was as much use as a bull in a china shop!
Paul knapp
New php-forum User
New php-forum User
 
Posts: 6
Joined: Fri Jan 31, 2003 10:40 am


Return to PHP General

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron