john_zakaria Posted November 17, 2008 Share Posted November 17, 2008 -------------------------------------------------------------------------------- i want to make the following using cookies When any user access the website, if this is the first time for him, he has to fill a form as follows Name Email City Country Telephone number [area code] + [phone number] After filling the above fields and submitting, the site wants all above to be saved on users machine as cookies, so that, after submission, when you close the browser, even the computer itself is closed and you opened the website again, you’ll not find the form with fields above, you’ll find instead the data inserted before. plz can anyone help me to do the following , i want to know if this need a database or not? and how to make it? i made this in page index.php <html> <body><form action="welcome.php" method="post"> Name: <input type="text" name="name" id="name" /> City: <input type="text" name="city" id="city" /> <input type="submit" /> </form></body> </html> and in welcome.php <html> <body>Welcome <?php echo $_POST["name"]; ?>.<br /> You are From <?php echo $_POST["city"]; ?> .</body> <? $expire=time()+60*60*24*30; setcookie("user2", $_POST["name"], $expire); //setcookie("user", "", 60); ?> <? if (isset($_COOKIE["user2"])) echo "Welcome " . $_COOKIE["user2"] . "!<br />"; else echo "Welcome guest!<br />"; ?> </html> i tested if i got it from my form and after that i tried to print my cookir name but it did not work can u help me plz Link to comment https://forums.phpfreaks.com/topic/133028-cookies-not-workingplz-i-need-help/ Share on other sites More sharing options...
revraz Posted November 17, 2008 Share Posted November 17, 2008 You probably have error displays and reporting turned off. If they were on, you would have received a HEADER error since you try to set a cookie after you have output to the browser. Read the HEADER sticky for more info. Link to comment https://forums.phpfreaks.com/topic/133028-cookies-not-workingplz-i-need-help/#findComment-692055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.