contra10 Posted December 9, 2008 Share Posted December 9, 2008 hi I 'm not too sure how to put the user id# that I assigned each user into the url...if it is possible, or how can I assign a url for the user in my community website? right now i'm using a session id... but its only till i can get a thorough understanding session_start(); $session_id = session_id(); header('Location: http://localhost/main/?sess_id='. $session_id); PLEASE HELP Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/ Share on other sites More sharing options...
amclean Posted December 9, 2008 Share Posted December 9, 2008 i *think* what you're looking for is $_GET. http://www.w3schools.com/PHP/php_get.asp Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-710868 Share on other sites More sharing options...
revraz Posted December 9, 2008 Share Posted December 9, 2008 Why would you need to put it in the URL if you are using sessions? Set the ID in a session variable and use that instead, much safer. Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-710883 Share on other sites More sharing options...
contra10 Posted December 10, 2008 Author Share Posted December 10, 2008 each user that I have has a specific user id number so are you saying let the user id = the session variable, and that would create a user specific profile page? Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-711112 Share on other sites More sharing options...
contra10 Posted December 10, 2008 Author Share Posted December 10, 2008 also i used $_GET before but it didn't work plus its probably too revealing i just want the profile pages to have an id so that i can perform searches that link to the user specific profile Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-711115 Share on other sites More sharing options...
timmah1 Posted December 10, 2008 Share Posted December 10, 2008 When the user logs in, set the session id loginsql = "SELECT * FROM users WHERE username = '$user' AND password = '$password'"; $loginres = mysql_query($loginsql); $numrows = mysql_num_rows($loginres); if($numrows == 1){ $loginrow = mysql_fetch_assoc($loginres); session_register("SESS_LOGGEDIN"); session_register("SESS_USERID"); $_SESSION['SESS_LOGGEDIN'] = 1; $_SESSION['SESS_USERID'] = $loginrow['user_ID']; } Then on the page you need to view that particular users profile, select their information from their session_id session_start(); $session_id = $_SESSION['SESS_USERID']; $sql = "select user_id where user_id = '$session_id'; Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-711122 Share on other sites More sharing options...
contra10 Posted December 10, 2008 Author Share Posted December 10, 2008 I placed this code on my main page index.php $loginsql = "SELECT id FROM registration WHERE username = '$username'"; $loginres = mysql_query($loginsql); $numrows = mysql_num_rows($loginres); if($numrows == 1){ $loginrow = mysql_fetch_assoc($loginres); session_register("SESS_LOGGEDIN"); session_register("SESS_USERID"); $_SESSION['SESS_LOGGEDIN'] = 1; $_SESSION['SESS_USERID'] = $loginrow['user_ID']; } and then i placed the second halk of th code on the main page which is where the profil is...still it doesn't show anything in the URL. I'm really confused, by the way thanks for the quick replies. WEBSITE LOGIN PAGE goes to MAIN PAGE and from there to PROFILE PAGE is there an easier way where i can jus retrieve the id from mysql and put it in the url, If i do use $_GET when doing a search of all the users, cause eventually i want to be able to do a search is there a way i can make the url specific to the actual user? Quote Link to comment https://forums.phpfreaks.com/topic/136268-solved-user-specific-profile-id-in-url/#findComment-711419 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.