Jump to content

Archived

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

Bavilo

Mysql and Sessions

Recommended Posts

Hello everyone,

I'm helping a friend with some scripting. I made a register and login script that takes the raw input and puts it into a database, the password is encrypted in md5, that part works, aswell as the login part but i need to display a unique page for each user. Basically my friend will create the usernames and passwords with the register script, lets say the username is 123 and the password is 321, when i enter 123 in the login box and i successfully login the page should now display information about only the user "123" such as a schedule, of things this user has to do and so on. I was thinking about using something like this.

[code]
<?
    if (isset($_SESSION['s_username'])) {
    echo "<b>Welcome</b> ".$_SESSION['s_username']."!"; }
  ?>
[/code]

This will display the name of the username that was entered in the login script, but instead i want it to check what username was entered, (in this case "123") take that username, check if its in the database and use that in the session code above instead of "username". Also, if 123 is logged in, it will not echo
[code]
<b>Welcome</b> ".$_SESSION['s_username']."!";
[/code] , but other php snippets, codes, html, whatever.

Ok just to wrap it up, what i am trying to figure out is how to change the content on a page such as a schedule that will be different for every user that signs on. Hopefully someone can point me to some examples or explain how this could be done. If anything is unclear please let me know, i will try to explain it some more.

Thanks
Mike

Share this post


Link to post
Share on other sites
Stoe a users info in the datebase, then simply run a query like...
[code]
$sql = "SELECT * FROM users WHERE user_id = {$_SESSION['id']};";
[/code]

Share this post


Link to post
Share on other sites

×

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.