Hi. I'm trying to store in a cookie the info a client submits (name, address, email, city, state etc.) Next time they visit, the script reads the cookie and fills out the text boxes.
I've setup two functions in require.php.
The user submits the info in userInfo.php and sends a hidden value "remember='Yes'" to Order.php which calls the function to store the cookie:
function setTheCookie($Name,$BuyAddress1,$BuyAddress2,$BuyCity,$BuyState,$BuyZip,$BuyEmail,$DayPhone,$EvePhone) {
setcookie ("cookie[Name]", $Name,time()+15552000);
setcookie ("cookie[BuyAddress1]", $BuyAddress1,time()+15552000);
setcookie ("cookie[BuyAddress2]", $BuyAddress2,time()+15552000);
setcookie ("cookie[BuyCity]", $BuyCity,time()+15552000);
setcookie ("cookie[BuyState]", $BuyState,time()+15552000);
setcookie ("cookie[BuyZip]", $BuyZip,time()+15552000);
setcookie ("cookie[BuyEmail]", $BuyEmail,time()+15552000);
setcookie ("cookie[DayPhone]", $DayPhone,time()+15552000);
setcookie ("cookie[EvePhone]", $EvePhone,time()+15552000);
}
When the user revisits and goes to userInfo.php to check out, the 2nd function is called:
function getTheInfo() {
if (isset ($cookie)) {
while (list ($name, $value) = each ($cookie)) {
echo "$Name == $value<br>\n";
}
}
}
The code is not finished cause I don't know what to do from here on to fill out the text boxes. Also, the return of the function getTheInfo is
John Doe == John Doe
John Doe == 1916 21 street
John Doe == ap 3B
John Doe == Brooklyn
John Doe == NY
John Doe == 11235
John Doe == appanos@hotmail.com
John Doe == (718) 555 - 6555
John Doe == 718 555-5555
John Doe == Panos
John Doe == appanos@hotmail.com
John Doe == 718 555-6555
first. instead of being
name == John Doe
address1 == 1916 21 street etc,
as u can see it's all John Doe.
Second, after the last filed, it starts repeating the info and I think it's from the previously set cookie that was overwritten by the new one.
I hope I didn't confuse u.
Any help with either this code, or, some other piece of code u may have would be appreciated.
Thanks a lot,
Panos A