SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict joyce's Avatar
    Join Date
    Aug 2001
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help me pls.....

    i have a login page, where i login, i will go to a page where show all the options which can let user to choose.

    everything has been working alrite....until i add the login for moderator. now when i choose the options, i will jump back to the login page. i dono wat is wrong..pls help!!


    this is the thing that i added, for moderator and admin login.
    PHP Code:
    if ((trim($login) == '' || trim($pass) == '') && trim($my_pass) == '' && trim($mod_pass) == '')
    {
        
    printheader();
        
    login(1);
        
    printfooter();
        print 
    "<hr style=\"border-style: outset\">\n";
        exit;
    }

    $result mysql_query("SELECT * FROM login_review WHERE login_name = '$login' AND login_passwd = '$pass'");

    if (
    $result
    {
        list (
    $login_ID$login_name$login_passwd$login_sta) = mysql_fetch_row($result);
    }
    else 
    {
        if (
    mysql_num_rows($result) < 1)
        {
            
    // Nothing returned, password was invalid
            
    echo "Wrong password or account doesn't exist for that user!";
            exit;
        }
        
    // Password is OK - log the user in
        
    else 
        {
            print 
    "MySQL Error: " mysql_error();
            exit;
        }
        
    }
    $script getenv("SCRIPT_NAME");

    session_start();
    $flat 0;
    if (
    $action == 'login'
    {    
        if (
    $pass == $login_passwd && $login_sta == 'a'
        {
            
    $my_pass $pass;
            
    $stat $login_sta;
            
    session_register("my_pass");
            
    session_register("stat");
        }
        elseif (
    $pass == $login_passwd && $login_sta == 'm'
        {
            
    $mod_pass $pass;
            
    $stat $login_sta;
            
    session_register("mod_pass");
            
    session_register("stat");
        }
    }
    else
        if (
    $action == 'config' && $do == 'password' && $do2 == 'password'
        {
        
            if (
    $old_admin_password == $login_passwd && $new_admin_password == $new_admin_password2
                {
                    
    $sql "UPDATE login_review SET login_passwd = '$new_admin_password'";
                    
    mysql_query($sql);
                    
                    
    $my_pass $new_admin_password;
                    
    session_register("my_pass");
                    
    $login_passwd $new_admin_password;
                    
    $flat 1;
                }
        }
        else 
        {
        
            
    $my_pass $HTTP_SESSION_VARS["my_pass"];
            if (
    $action == 'logout'
            {
                            
    session_destroy(); 
                            } 
    these are all the action carried out when i choose the option:
    PHP Code:
    if ($action == 'login'
    {
        if (
    $login == $login_name && $pass == $login_passwd
        {            
            
    show_panel();
        }
        else 
        {
            print 
    "<p align=center>Incorrect Password!</p>";
        }
    }
    elseif (
    $action == 'logout'
    {
            
    logout();
    }
    else 
    {
            if (
    $login != $login_name || $my_pass != $login_passwd
            {
                
    login();
            }
            else 
            {    
                if (
    $action == 'add')         
                {
                    
    add();
                }
                elseif (
    $action == 'editUser')         
                {
                    
    editUser();
                }
                elseif (
    $action == 'editMod')         
                {
                    
    editMod();
                }
                elseif (
    $action == 'addMod')     
                {
                    
    addMod();
                }
                elseif (
    $action == 'addRe')     
                {
                    
    addRe();
                }
                elseif (
    $action == 'writeRe')     
                {
                    
    writeRe();
                }
                elseif (
    $action == 'viewModRe')     
                {
                    
    viewModRe();
                }
                elseif (
    $action == 'viewUserRe')     
                {
                    
    viewUserRe();
                }
                elseif (
    $action == 'config'
                {
                    
    config();
                }
                else         
                {
                    
    show_panel();
                }
            }
        } 
    this is the function show panel() where i can choose the options:
    PHP Code:
    function show_panel() 
    {
        global 
    $script$view_mod$view_user$mod_pass$my_pass$stat;

        
    $result mysql_query("SELECT * FROM config_review");
        if (
    $result
        {
            list(
    $header$footer$url_site$url_image$font_face$font_color$table_border_color$table_color_1$table_color_2$view_mod$view_user$cat_mod$re_mod) = mysql_fetch_row($result);
        }

        print 
    "<script language=\"JavaScript\">\n";
        print 
    "<!-- \n";
        print 
    "function GoOption(action) {\n";
        print 
    "    if (action != '') {\n";
        print 
    "        document.option.submit();\n";
        print 
    "        }\n";
        print 
    "    }\n";
        print 
    "\n";
        print 
    "// -->\n";
        print 
    "</script>\n";
        print 
    "<table border=0 cellspacing=0 cellpadding=0 width=100%>\n";
        print 
    "    <tr><td valign=top><font color=\"#ffffff\" face=Verdana size=2><b>Review Administration Panel</b></font></td><td valign=top align=right>";
        
    options();
        print 
    "</td></tr>\n";
        print 
    "    <tr><td colspan=2 valign=middle align=center>\n";

        print 
    "<form action=\"$script\" method=\"post\">\n";
        print 
    "<table border=0 cellspacing=0 cellpadding=1 bgcolor=#ffffff width=500 align=center><tr><td>\n";
        print 
    "<table border=0 cellspacing=1 cellpadding=1 width=100%>\n";
        if (
    $cat_mod == 'y' || $stat == 'a'
        {
            print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Category</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=add></td></tr>\n";
        }
        
        if (
    $stat == 'a'
        {
            print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Moderator</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=addMod></td></tr>\n";
        }

        if (
    $cat_mod == 'y' || $stat == 'a'
        {
        print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Add a Reviewed Item</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=addRe></td></tr>\n";
        }
        print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Write A Review </b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=writeRe></td></tr>\n";
        
        if (
    $view_mod == 'y' && $stat == 'a'
        {
            print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>View Moderator's Review</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=viewModRe></td></tr>\n";
        }
        if (
    $view_user == 'y' && $stat == 'a'
        {
            print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>View User's Review</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=viewUserRe></td></tr>\n";
        }
        if (
    $stat == 'a'
        {
            print 
    "<tr><td bgcolor=#9999ff width=100%><font face=\"Verdana\" color=\"#ffffff\" size=2><b>Edit Review Configurations</b></font></td><td bgcolor=#9999ff align=right><input type=radio name=action value=config></td></tr>\n";
        }
        
        print 
    "</table>\n";
        print 
    "<tr bgcolor=#000099><td>&nbsp;</td></tr>";
        print 
    "<tr bgcolor=#000099><td align=right><input type=submit value=\"Do it!\" style=\"background-color: #9999ff; font-family: Verdana; font-weight: bold; color:#ffffff\"></td></tr>\n";
        print 
    "</td></tr></table>\n";
        print 
    "</form>\n";
        print 
    "    </td></tr>\n";
        print 
    "</table>\n";


  2. #2
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this is your problem:

    PHP Code:
    if ($result
    {
        list (
    $login_ID$login_name$login_passwd$login_sta) = mysql_fetch_row($result);
    }
    else 
    {
        if (
    mysql_num_rows($result) < 1)
        {
            
    // Nothing returned, password was invalid
            
    echo "Wrong password or account doesn't exist for that user!";
            exit;
        }
        
    // Password is OK - log the user in
        
    else 
        {
            print 
    "MySQL Error: " mysql_error();
            exit;
        }
        

    You say: if the result is less than 1 then there is no user, if it is greater than 1, then it is OK so log them in. But there is no code to actually log them in, instead the else part of the statement simply tells the script to exit.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •