Jump to content

[SOLVED] Bit of troubles with a login script.


labine50

Recommended Posts

I'm pretty new to PHP and SQL in general. I've basically been doing web development solely in HTML for the last 16 months, (Basically the entire time I've been doing web development) and figured it was time to learn some new stuff. Learning can't hurt, no?

 

Anyway, I play this mildly popular MMO and my group has a website which needs password protection. So far the security system has been based on trying to keep it off of Google. I followed the Tutorial here and made a very simple login system. Unfortunately, it doesn't allow the option to register and seems to only protect one page.

 

The registration thing I should be able to figure out on my own, but for the mutli-page protection... I basically have an entire directory that needs to be protected. Can anybody make recommendations on this?

Well, I honestly don't feel like reading the tutorial because it's probably bad code in the first place and I'd rather not comment on it (most tutorials these days are old and outdated).  Do you login with sessions or cookies?

 

It includes this-

<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

 

So I think it's sessions.

Oh boy I knew that there would be bad code.  They're using deprecated session functions. >_<  You don't need any session_* functions other than like session_start() and session_destroy() because the $_SESSION superglobal is now usable for writing to sessions.  And to protect any page, just put that code on the top of the page.  Like the very top before any output.  But you should really learn a bit of PHP and clean it up.

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.