Register and Login (Email Activation) and User profile

Post here is you are having problems with any of the tutorials.
Post Reply
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

Register and Login (Email Activation) and User profile

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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.
Image
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post by kalipsso »

the thing is that the user_list.php does not get my user_id...

[syntax=php]<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>[/syntax]
What is the problem???
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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?
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 :)
Image
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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 [syntax=php]<?php echo $user['id']; ?>">[/syntax]
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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:
[syntax=php]$_SESSION['uid'] = 1;[/syntax]
to reflect the logged in ?
Thanks in advance
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 :?
Image
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post by jacek »

You can get the users id from the database and store it in the session when they login ...
Image
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post by jacek »

You know how to check to see if the user is logged in ? you need to use that.
Image
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post by kalipsso »

Yeah...i was expecting this answer.. :P
You don't want to give any tips... lol :D
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

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

Post 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.....
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

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

Post 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.

[syntax=php]function is_logged_in(){
if(empty($_SESSION['username'])){ return false; }else{ return true; }
}[/syntax]

[syntax=php]if(is_logged_in === false){Show login form}else{don't show login form}[/syntax]
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

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

Post 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.

[syntax=php]function is_logged_in(){
if(empty($_SESSION['username'])){ return false; }else{ return true; }
}[/syntax]

[syntax=php]if(is_logged_in === false){Show login form}else{don't show login form}[/syntax]

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...
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

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

Post 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.

[syntax=php]function is_logged_in(){
if(empty($_SESSION['username'])){ return false; }else{ return true; }
}[/syntax]

[syntax=php]if(is_logged_in === false){Show login form}else{don't show login form}[/syntax]

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.
Post Reply