Jump to content

Login - Carrying the variable


jaybeeb

Recommended Posts

Ok, I have a working login form, the only thing the user enters in the form is username and password. But I want to carry the value 'id' which is in the user table along with the username and password to the next page so I can make the page unique for each user. 'id' is set up to auto-increment when each user registers.

 

What I have at the moment is

header("location:userpage.php?id=$id");

but I am not sure how to get the actual id of the user that logs in into that variable, it just comes up blank at the moment.

 

Any help would be greatly appreciated...

 

Link to comment
https://forums.phpfreaks.com/topic/129828-login-carrying-the-variable/
Share on other sites

Are you saying that every time a user logs in they get a new/different (auto increment) id?

Hi,

No - everytime a user registers they get a unique 'id' I want to use this id to display the info relevant to each user. Just need a way of getting the id into a variable, so when the user clicks login, the variable goes with them and I can use it on the next page they go to.

 

Your page isn't giong to be secure, because people could just mimick the url example:

userpage.php?id=1

or userpage.php?id=2,

etc...

 

with the id="some number" and take over that user.

 

Why do it like that ?

 

Why not make it unique for each user by storing there id in a session ?

 

To be honest, i am just beggining php, this is just for a small assignment, if storing the id in a session is a simple enough proccess I would like to hear it if you wouldnt mind?

 

Ok, Put session_start(); on the top of everypage , then put on the login where the header is

$_SESSION['id'] = $id;

 

ok, thanks. But now how do I make it so each user has their own unique page when they login. Like to say "Hello '$username' you are now logged in" before I was just going to do an sql statement calling the 'id'

 

Thanks for the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.