Advertisement:

Making sure a user is logged in...

Aloittaja Henry_n, marraskuu 23, 2005, 05:23:45 IP

« edellinen - seuraava »

Henry_n

Hello,

I recently purchased a great PHP/MySQL book on integrating that stuff with flash. I've known a little PHP for a while, but now I'm finally understanding more, as well as how to use it as a server-side script.

I'm making a type of game that saves the records (user's stats/levels, preferences, etc), but for their username, I want them to be "forced" into using their forum username; not only that, but they must also be logged into the forums. This will help finding trouble-makers/abusers. I still am learning about sessions, so I'm planning on using them to help with this, but how would I be able to access a user's SMF forum's cookie (obviously for my forums, not the real SMF forums; ie: these).

For their password, I think I'll just use the SHA1() function, but I'm a bit iffy on it because I'm not sure just how secure that can be. (Any suggestions?)

But yeah, I'm wondering how I can make it so that they have to use their real forum username. My only guess was with cookies. Along with this, it'd be nice to have them actually be signed in, but this isn't necessary.

(Realise that I'm still fairly new to PHP and MySQL, so if you need to put it into "nooby" terms, that's ok).

[Edit]

Hmmm, perhaps I could use the SSI to make sure they're a member on the forums (by checking to see if they're logged in), and I could extract their username from a variable in that.

Any help here would be very benificial =)

rakuli

Yes, the easiest way would be to use SSI.php and you can access their user name using $context['user']['username']

You can check to see if they are logged with

if ($context['user']['is_logged']) {
echo $context['user']['username'] . ', you may proceed to play the game';
} else {
echo 'Ooops, you need to be a member of the forum -- and logged in -- to play this game';
}

Henry_n

Thank you very much; it worked exactly as I'd hoped it did =)

Thantos

Also you can do:
is_no_guest("Before playing this game you must register");

It'll check to see if they are a guest, if so it'll give them the login screen with the specified error message.  Upon login they'll be returned to that page.

Advertisement: