dh526 Posted May 19, 2009 Share Posted May 19, 2009 Sorry for starting another thread but I still was a bit confused :S Here is the problem, I just want to create a (very) simple login system. Any help would be much appreciated I have login.html <html> <head> </head> <body> Please login <br> <form method="post" action="login1.php"> username:<input type="text" name= "username"/> <br> <input type="submit" /> </form> </body> </html> and login1.php <html> <head> </head> <body> <? $username = $_POST ['username']; setcookie('username', $username); echo "<a href="login2.php">LINK</a>"; ?> </body> </html> and then i want to show the username in another page, called login2.php <? echo $_COOKIE['username']; ?> again, I don't know why this isn't working :S I feel like it makes sense :S Sorry, I feel such a plonker while doing this sometimes ... Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/ Share on other sites More sharing options...
ohdang888 Posted May 19, 2009 Share Posted May 19, 2009 you're not setting the expiration date... use this: setcookie("username", $username, time()+3600); Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/#findComment-837721 Share on other sites More sharing options...
dh526 Posted May 19, 2009 Author Share Posted May 19, 2009 Nope, this still doesn't work Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/#findComment-837734 Share on other sites More sharing options...
void Posted May 19, 2009 Share Posted May 19, 2009 echo $username = $_POST ['username']; // check if this variable isn't empty setcookie('username', $username); echo "<a href="login2.php">LINK</a>"; Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/#findComment-837741 Share on other sites More sharing options...
studygirl15 Posted May 19, 2009 Share Posted May 19, 2009 hey dh526. I do not know a lot about code, but i managed to get my login system to work XD i was thinking... since were both kinda new to code, and learning.. maybe we could be friends and work together to learn if u wanted lol Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/#findComment-837744 Share on other sites More sharing options...
ohdang888 Posted May 21, 2009 Share Posted May 21, 2009 hey dh526. I do not know a lot about code, but i managed to get my login system to work XD i was thinking... since were both kinda new to code, and learning.. maybe we could be friends and work together to learn if u wanted lol uh. possible pedophile? sorry if that offends, just my first reaction when reading this on an online forum. Link to comment https://forums.phpfreaks.com/topic/158829-php-cookies-s/#findComment-838589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.