Jump to content
xisto Community
fffanatics

Php Login Script Removing the login field once the user logs in

Recommended Posts

Hmmz thanks for the help but i am not looking to really rewrite a good amount of my code. I just was wondering if anyone knew how i could fix this error since it must be a small one if i dont get it on my server but do get it on the Xisto one

Share this post


Link to post
Share on other sites

Hey everyone thanks for your help. My login script works 100% now. The error was because i had a blank line after the ?> in the one file i included. Thanks for all of your great ideas and solutions

Share this post


Link to post
Share on other sites

Why not just use cookies to keep your users logged in? It's a lot easier using sessions, in my opinion. All you would have to do is add a new variable to the config file that is something like this:

$username = (isset($_COOKIE['user']) ? $_COOKIE['user'] : Guest);

login.php

<?php# Include all the needed filesif (isset($_POST['login'])) {    $uname = $_POST['username'];    $pword = $_POST['password'];    $check = mysql_query("SELECT username FROM users WHERE username='$uname' AND password='$pword'") or die(mysql_error());    if (mysql_num_rows($check) == 0) {         echo 'Invalid username or password';         exit;    } else {        setcookie('user', $uname, time()+999999);        setcookie('pword', $pword, time()+999999);        echo 'You have successfully logged in!  Return to the <a href="/">index</a>.';    }} else {    echo '';    }?>

Share this post


Link to post
Share on other sites

Yes my code does work and i do actually use cookies. I use to cookies so that they have the option of not having to sign in for 2 weeks. However, this is the only information that is cantained in the cookie. Personally, i like sessions cause its very easy to use and is a secure way to send and recieve information from a page

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.