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
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?

 

Link to comment
Share on other sites

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.

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.