Page 1 of 1

Register and Login (Email Activation) and User profile

Posted: Thu Jun 09, 2011 3:06 pm
by kalipsso
How do we combine the 2 scripts together?
What modifications are needed for this 2 to work together?
I added the code from the profile user.inc.php to the user.inc.php from Login/Register file, made the modifications to connect to the same database, i added the tables in the database... i registered a user activated it and when i go to profile.php page, i get this result:"That user does not exist. "
What did i do wrong?

Best regards and any help will be appreciated.

Re: Register and Login (Email Activation) and User profile

Posted: Thu Jun 09, 2011 3:22 pm
by jacek
This kind of question is not going to get you many replies, instead of asking how to combine two tutorials, have a go yourself then post any problems you have along with the code you tried to use.

Re: Register and Login (Email Activation) and User profile

Posted: Thu Jun 09, 2011 3:31 pm
by kalipsso
the thing is that the user_list.php does not get my user_id...
<div>
		<?php
		
		foreach (fetch_users() as $user){
			?>
			<p>
				<a href="profile.php?uid=<?php echo $user['id']; ?>"><?php echo $user['username']; ?></a>
			</p>
			<?php
		}
		
		
		
		?>
	</div>
What is the problem???

Re: Register and Login (Email Activation) and User profile

Posted: Thu Jun 09, 2011 3:45 pm
by kalipsso
OK...fixed for now ;)

BTW...is there any way you can make a tutorial on how to add user avatar or profile picture?

Re: Register and Login (Email Activation) and User profile

Posted: Thu Jun 09, 2011 4:12 pm
by jacek
kalipsso wrote:OK...fixed for now ;)
What was the problem ? ;)
kalipsso wrote:BTW...is there any way you can make a tutorial on how to add user avatar or profile picture?
there is a suggestions section, if you have a tutorial suggestion, post it there :)

Re: Register and Login (Email Activation) and User profile

Posted: Fri Jun 10, 2011 8:08 am
by kalipsso
jacek wrote:
kalipsso wrote:OK...fixed for now ;)
What was the problem ? ;)
kalipsso wrote:BTW...is there any way you can make a tutorial on how to add user avatar or profile picture?
there is a suggestions section, if you have a tutorial suggestion, post it there :)
the problem was that i save the file without adding the echo from
<?php echo $user['id']; ?>">

Re: Register and Login (Email Activation) and User profile

Posted: Fri Jun 10, 2011 11:30 am
by kalipsso
i am getting this error on edit_profile.php:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\xampp\htdocs\avatar\profiles\edit_profile.php:1) in D:\xampp\htdocs\avatar\profiles\core\init.inc.php on line 2
i have removed the session_start from init.inc.php and the error disappeared.
also...what do i need to put to replace this code:
$_SESSION['uid'] = 1;
to reflect the logged in ?
Thanks in advance

Re: Register and Login (Email Activation) and User profile

Posted: Fri Jun 10, 2011 3:35 pm
by jacek
Removing session_start() is not the correct way to fix that, as it is needed for the session to work. The problem is that the session_start() function needs to send a cookie which has to be done via a header, and headers cannot be sent after output from the script has begun. The correct fix would be to remove any output from the script before the session_start line.

And I don't really know what you mean by the other thing :?

Re: Register and Login (Email Activation) and User profile

Posted: Fri Jun 10, 2011 5:47 pm
by kalipsso
jacek wrote:Removing session_start() is not the correct way to fix that, as it is needed for the session to work. The problem is that the session_start() function needs to send a cookie which has to be done via a header, and headers cannot be sent after output from the script has begun. The correct fix would be to remove any output from the script before the session_start line.

And I don't really know what you mean by the other thing :?
$_SESSION['uid'] = 1; means that the user with id 1 is logged in.
As i told you, i use it with login - register tutorial script...How do i make it so, that when the user login to be able to edit his profile?
So i need to change there something...
If you wold-of continue with the register-login tutorial to make the user profile page, what was the code you put there in init.inc.php?
TKS.

Re: Register and Login (Email Activation) and User profile

Posted: Fri Jun 10, 2011 6:34 pm
by jacek
You can get the users id from the database and store it in the session when they login ...

Re: Register and Login (Email Activation) and User profile

Posted: Sun Jun 12, 2011 2:31 pm
by kalipsso
Something is not complete in register/log-in script.
Because when a user is logged in, it still shows the log-in form..
What does it need to be added so when a user is logged in to show the log-out button(link) if he visit the log-in page again after he logs in?
Regards.

Re: Register and Login (Email Activation) and User profile

Posted: Sun Jun 12, 2011 3:03 pm
by jacek
You know how to check to see if the user is logged in ? you need to use that.

Re: Register and Login (Email Activation) and User profile

Posted: Sun Jun 12, 2011 10:33 pm
by kalipsso
Yeah...i was expecting this answer.. :P
You don't want to give any tips... lol :D

Re: Register and Login (Email Activation) and User profile

Posted: Sun Jun 12, 2011 10:39 pm
by EcazS
kalipsso wrote: You don't want to give any tips... lol :D
I'm sorry what?
You know how to check to see if the user is logged in ? you need to use that.
Sorry you're right, that's not a tip, he's actually telling you what you have to do.....

Re: Register and Login (Email Activation) and User profile

Posted: Sun Jun 12, 2011 10:43 pm
by Temor
Since I get the feeling you're not gonna do this yourself, I will provide you with one really easy function that checks if the user is online or not.
function is_logged_in(){
	if(empty($_SESSION['username'])){ return false; }else{ return true; }
}
if(is_logged_in === false){Show login form}else{don't show login form}

Re: Register and Login (Email Activation) and User profile

Posted: Mon Jun 13, 2011 7:32 am
by kalipsso
Temor wrote:Since I get the feeling you're not gonna do this yourself, I will provide you with one really easy function that checks if the user is online or not.
function is_logged_in(){
	if(empty($_SESSION['username'])){ return false; }else{ return true; }
}
if(is_logged_in === false){Show login form}else{don't show login form}
Thanks...i already tried that but does not work...it seems like the user is not logged out when i click the log out button...and is not showing the log-in form when i add that code...

Re: Register and Login (Email Activation) and User profile

Posted: Mon Jun 13, 2011 12:12 pm
by Temor
kalipsso wrote:
Temor wrote:Since I get the feeling you're not gonna do this yourself, I will provide you with one really easy function that checks if the user is online or not.
function is_logged_in(){
	if(empty($_SESSION['username'])){ return false; }else{ return true; }
}
if(is_logged_in === false){Show login form}else{don't show login form}
Thanks...i already tried that but does not work...it seems like the user is not logged out when i click the log out button...and is not showing the log-in form when i add that code...
That's probably because you're not setting the $_SESSION['username'] variable. You're setting the $_SESSION['uid'] variable.