Hi! I've been trying to work on with my very own PHP login script(PHP+MySQL). Managed to get the login part work with cookies. Is there a better way to do it? I was wondering if HTML5 gives a new point of view in building a login system..

But so far I have also a problem. How can I prevent an inlogged user not to see the actual login page.(in this case login.php which contains the login form, which gives all login data to takelogin.php) I tried making a PHP script in the top of login.php: when an inlogged person hits url ..../login.php, it first checks if there is allready a cookie registered with his username. If there is, then it redirects to user home page. If there's not, login.php loads completly.

That idea didn't turn out well. Or I just couldn't figure it out in right way. So can someone consultate me with this? :)

Recommended Answers

All 4 Replies

Your idea should work just fine. Perhaps there was just an error in your code somewhere.

Am not quite sure what you are expecting from HTML5 to do differently.

Thanks for your reply, pritaeas! :) It was a good advice to look back to code i've been writing. Actually it works now! As you said idea works just fine. I did a minor mistake with marking. Instead of doing it like this

if (isset($_COOKIE['username']))

it should be written like this

if (isset($_COOKIE["username"]))

So as a statement IT SEEMS TO WORK NOW! THANKS!

For the HTML5 question, I am totaly new with it. Just read an article about it and there was something said HTML5 has an ability to store data etc... So I thougt if that could replace somehow MySQL as a storage of data.

Glad you got it working, but both statements should be working identical. I think you must've change something else.

Ouh... Then, you're probably right. I may have misspelled or something. After all, I'm happy it works now, and also about how fast you can get help from here! DaniWeb rulez! ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.