bluedot Posted December 14, 2006 Share Posted December 14, 2006 Hi,I have a pretty simple member login, if the entered password and username are in the database it takes the user to a very simple control panal where they can edit things on the site.I have a table in a database that has the usernames, passwords, first names, last names, and emails in it.All I want is the name that corrasponds with the entered username to be displayed in the simple control panel.I know a very round about way of doing it with hidden fields in an HTML form but i'd like to do it with superglobals, but i can't find a tutorial that i can understand.I would greatly appriciate if somebody would break superglobals down to laymen terms and show me how to do this. Thanks! Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/ Share on other sites More sharing options...
trq Posted December 14, 2006 Share Posted December 14, 2006 How are you [i]loging in[/i] users? I meen, have you anything setup to stop me (if I knew the address of this [i]admin[/i] page) going directly to it?You need to find a tutorial on a [i]php login system[/i]. Google should have MANY such tutorials.Most login systems use the $_SESSION super global array to maintain a users identity. Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/#findComment-140879 Share on other sites More sharing options...
bluedot Posted December 14, 2006 Author Share Posted December 14, 2006 If the password and username they entered are in the database then this is executed:[code]setcookie("loggedin", "TRUE", time()+(3600 * 24)); setcookie("mysite_username", "$username");[/code]then on each page that i want restricted i have:[code]if (!isset($_COOKIE['loggedin'])) die("You are not logged in!");$mysite_username = $HTTP_COOKIE_VARS["mysite_username"];[/code]I tried google.. but people always make their programs so big and explain so little of it that i get lost. I just need the most simplistic breakdown of how superglobals work.. Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/#findComment-140883 Share on other sites More sharing options...
fert Posted December 14, 2006 Share Posted December 14, 2006 [code]setcookie("mysite_username", "$username");[/code]should be[code]setcookie("mysite_username", $username,0,"www.mysite.com",0);[/code]and[code]$mysite_username = $_COOKIE['mysite_username'];[/code] Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/#findComment-140886 Share on other sites More sharing options...
bluedot Posted December 14, 2006 Author Share Posted December 14, 2006 that does'nt seem to work, it prints a blank.what are the 0's for in[code]setcookie("mysite_username", $username,0,"www.mysite.com",0);[/code]? Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/#findComment-140890 Share on other sites More sharing options...
trq Posted December 14, 2006 Share Posted December 14, 2006 [quote]what are the 0's for[/quote]How about looking up the [url=http://php.net/setcookie]setcookie[/url] function in the manual? It explains things in much more detail than we can and you don't have to wait for an answer. Link to comment https://forums.phpfreaks.com/topic/30595-superglobal-variables-question/#findComment-140893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.