Jump to content

[SOLVED] user specific profile id in url


contra10

Recommended Posts

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

Link to comment
Share on other sites

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';

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.