how to save HTML form values to cookie using PHP?

Name

New member
i have written a php code that saves a cookie containing a certain value then another cookie to retrieve that value, like that:
<?php
$inTime = 60 * 60 * 24 * 60 + time();
$txt = date("D, M/d/Y")."***".'never been here';

setcookie('mylastvisit',$txt ,$inTime);
?>

<?php

if(isset($_COOKIE['lastvisit'])) {
$visit = $_COOKIE['lastvisit'];

echo "Your last visit was - ". $visit;
}

else
{echo "Cookie NOT Working!"; }

<br />

echo isset($_COOKIE['lastvisit'])? $_COOKIE['lastvisit'] : ''
?>

//--------------------------------------------------------
then i added a form with three text areas and a submit button to let the user write in 'em, now i need to make the form save what the user writes in a cookie so as to retrieve it later before being saved to database...
and can i make a button to save to a cookie and a button to save to database?
can i make the values get saved to cookie automatically???

form goes like::

<form>
<input type="text" name="box1" />
<input type="text" name="box2" />
<input type="text" name="box3" />
<input type="text" name="box1" />
<input type="submit" value="submit" name="submit" />

any help is much appreciated!!
 
Back
Top