Login issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    Login issue

    Login issue in this code when i enter to the login page the login form still visible how can i solve this problem ?

    [PHP]
    <?php if(!($_SESSION['userLOGIN'])){ ?>
    <form method='post' action='Login.p hp' id="LOGINFORM" >
    Username:
    <input name='user' type='text' id='user' size='20' maxlength='15' />
    <br />
    Password:
    <input name='pass' type='password' id='pass' size='20' maxlength='15' />
    <br />
    <span style='color: 999933;font-size: 9px;'><a href='#'>Forget Password</a> / <a href='Signup.ph p'>Signup</a></span>
    <input type='submit' name='button' id='button' value='Login' />
    </form>
    <?php } ?>

    <?php

    if($_SESSION['userLOGIN']){
    echo "Welcome ".$_SESSION['userLOGIN']." You are now logging in <input name='' type='button' value='GO' onclick='alert( )'/>";
    }else{
    $userLOGIN = $_POST['user']; $userLOGIN = secure($userLOG IN);
    $passLOGIN = $_POST['pass']; $passLOGIN = secure($passLOG IN);
    if($userLOGIN == "" || $passLOGIN == ""){
    echo "<span class='RED'>Ple ase Fill all fields</span>";
    }else{
    include_once("C onnections/conection.php") ;
    $result=mysql_q uery("SELECT username,Passwo rd FROM users WHERE username='$user LOGIN' && Password=PASSWO RD('$passLOGIN' )",$myConnectio n);
    if(mysql_num_ro ws($result)==1) {
    echo "Welcome $userLOGIN you are now logedin";
    session_registe r("userLOGIN" );
    }else{
    echo "<span class='RED'>You r not registerd in this site please try again or <a href='Signup.ph p'>Signup</a></span>";
    }
    }
    }

    ?>[/PHP]
  • dafodil
    Contributor
    • Jul 2007
    • 389

    #2
    Originally posted by smartic
    [code=PHP]
    <?php if(!($_SESSION['userLOGIN'])){ ?>
    <form method='post' action='Login.p hp' id="LOGINFORM" >
    Username:
    <input name='user' type='text' id='user' size='20' maxlength='15' />
    <br />
    Password:
    <input name='pass' type='password' id='pass' size='20' maxlength='15' />
    <br />
    <span style='color: 999933;font-size: 9px;'><a href='#'>Forget Password</a> / <a href='Signup.ph p'>Signup</a></span>
    <input type='submit' name='button' id='button' value='Login' />
    </form>
    <?php } ?>

    [/code]
    try to echo the part inside the if statement.
    You should write it like this:

    [code=php]
    <?php
    if(!($_SESSION['userLOGIN'])){

    echo "<form....> ";
    echo "Username";
    echo "<input.... >";
    }
    ?>

    [/code]


    Make sure that you are entering the correct password and username.

    Check also the database if the username and password exist in the table.

    Comment

    Working...