ghurty Posted August 13, 2007 Share Posted August 13, 2007 Currently I am using the following script to store cookies if(isset($_GET['activelocation'])){ $activelocation = $_GET['activelocation']; setcookie('location', $activelocation, time()+60*60*24*30); } elseif(isset($_COOKIE['location'])){ $activelocation = $_COOKIE['location']; //if the cookie is set, get the value } else{ setcookie('location', 'New York, NY', time()+60*60*24*30); $activelocation = "New York, NY"; } But I realized that being I anyway have registered users on the my site, it would probably be better of storing it in their account preferences. How would I go about modify this so that instead of creating a cookie it stores it into a field in my user table? Also, I would want it that if the user is not logged in, then it will use cookies, but first it should look to see if person is logged in, and rather use that Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64632-modifying-a-script-to-store-information-into-a-table-rather-then-a-cookie/ Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 UPDATE users_table SET activelocation='$activelocation' WHERE loggedin=1 AND user_identity='$identity' That's a mysql query, that you could use. Quote Link to comment https://forums.phpfreaks.com/topic/64632-modifying-a-script-to-store-information-into-a-table-rather-then-a-cookie/#findComment-322243 Share on other sites More sharing options...
ghurty Posted August 13, 2007 Author Share Posted August 13, 2007 Thank you, But what string do I use to pull in the data back? Quote Link to comment https://forums.phpfreaks.com/topic/64632-modifying-a-script-to-store-information-into-a-table-rather-then-a-cookie/#findComment-322656 Share on other sites More sharing options...
uwannadonkey Posted August 13, 2007 Share Posted August 13, 2007 Select would take out the items from your mysql, and you use mysql_fetch_assoc or fetch object to echo it (if im not mistaken!) an example: $usersql = @mysql_query("SELECT * FROM users WHERE ID = '$uID'"); $user = @mysql_fetch_object($usersql); now, all colums in your database are stored with the variable $user to echo a column, you would type echo "$user->(columnname)"; Quote Link to comment https://forums.phpfreaks.com/topic/64632-modifying-a-script-to-store-information-into-a-table-rather-then-a-cookie/#findComment-322665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.