i'm confused and don't know what to do

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muchexie
    New Member
    • Feb 2007
    • 20

    i'm confused and don't know what to do

    i have developed a log in system which is a starting point for my online learning system i'm developing.
    i'm failing to log in possibly the system is not able to register a user as a valid user.The system is not reflecting error warnings.
    Here is a code section where i'm suspecting a fault.


    function login($username , $passwd)
    // check username and password with db
    // if yes, return true
    // else return false
    {
    // connect to db
    $conn = db_connect();
    if (!$conn)
    return 0;

    // check if username is unique
    $result = mysql_query("se lect * from users
    where username = '$username'
    and passwd = '$passwd'");
    if (!$result)
    return 0;

    if (mysql_num_rows ($result)>0)
    return 1;
    else
    return 0;
    }

    function check_valid_use r()
    // see if somebody is logged in and notify them if not
    {
    global $valid_user;
    if (session_is_reg istered("valid_ user"))
    {
    echo "Logged in as $valid_user.";
    echo "<br>";
    }
    else
    {
    // they are not logged in
    do_html_heading ("Problem:") ;
    echo "You are not logged in.Please try again.<br>";
    do_html_url("lo gin.php", "Login");
    //do_html_footer( );
    exit;
    }
    }


    <?
    session_start() ;
    // include function files for this application
    require_once("s ystem_fns.php") ;
    if (isset($usernam e) && isset($passwd))
    // they have just tried logging in
    {
    if (login($usernam e, $passwd))
    {
    // if they are in the database register the user id
    $valid_user = $username;
    session_registe r("valid_user") ;
    }
    }
    check_valid_use r();
    // give menu of options
    display_user_me nu();
    ?>


    Please help to get out of this situation
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Please read the Posting Guidelines before you post in this forum!.
    Especially the part about enclosing posted code within code or php tags!

    moderator

    Comment

    Working...