Results 1 to 12 of 12

Thread: [RESOLVED] Authentication Function HELP

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Resolved [RESOLVED] Authentication Function HELP

    Well recently i took upon a task.Which needed me to make an authentication function/system for it, and well.... i thought i'd go into an old project and use that one.... but.... then i found out... that my sister had gotten onto the computer and DELETED ALL OF MY PROJECTS!!!!!!!!!!!!!!!!!!!!

    sooo...here i am.lol

    My problem is this.
    I am trying to create an authentication system.Pretty basic explanation i know.
    When your not logged in. It works fine.But...
    For some reason when i use this code in my index.php page(Shown below).
    To determine if the user should be able to view the page(when logged in) or not. It will show the "You do not have a high enough rank to view this page."
    aswell as the content that shouldnt be able to be viewed by the user.

    Here Are the files.
    Config.php Not included As it's just the SQL connection.Atm.

    Index.php
    PHP Code:
    <?php
    session_start
    ();
    require(
    "functions.php");

    if(
    Authentication(5)){
    print(
    "Welcome");
    }
    ?>
    I remember at least this much.On how to call the function in the index.php.

    this is my functions.php page
    PHP Code:
    <?php
    include("config.php"); //Includes the connection to the database
    error_reporting(E_ALL ^E_WARNING ^E_NOTICE);

    // Start Authentication Functions    
        
    function Authentication($mRank){
            
    // Authentication Functrion
            
    if(isset($_POST['AuthLogin'])){

                
    $result mysql_query("SELECT * FROM users WHERE username='".$_POST['userName']."' AND password='".$_POST['passWord']."'");
                          
    extract($userinfo mysql_fetch_object($result));
                            
    $_SESSION['CuSeR']    =    $userinfo->username;
                            
    $_SESSION['CuSeR_ID']    =    $userinfo->ID;
                            
    $_SESSION['CuSeR_Rank']    =    $userinfo->rank;
                            
    $_SESSION['CuSeR_LastLogin']    =    $userinfo->lastlogin;
            
            }        
    //*                
            
    $result mysql_query("SELECT * FROM users WHERE username='".$_SESSION['CuSeR']."'");
            
    extract($userinfo mysql_fetch_object($result));
                
                print(
    "My Rank:".$userinfo->rank."<br />");
                print(
    "Needed Rank:".$mRank."<br />");
                
                if(
    $userinfo->rank >= $mRank){
                        
    //return true;
                        
    if(!$userinfo->ID){
                            
    //return false;
                            
    return loginForm();
                        }
                    }else{
                        
    //return false;
                        
    return print("You do not have a high enough rank to view this page.<br />\n");
                        
                    }            

        }
    //End Authentication Function
        
        
    function loginForm(){
            
    ?>
            <form action="index.php?module=Login" name="AuthLoginForm" method="post">
            <table width="15%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
      <tr>
        <td colspan="2" bgcolor="#999999"><div align="center">Login</div></td>
        </tr>
      <tr>
        <td width="8%" bgcolor="#999999">Username</td>
        <td width="92%" bgcolor="#999999"><input name="userName" type="text" value="UserName" class="login_text" /></td>
      </tr>
      <tr>
        <td bgcolor="#999999">Password</td>
        <td bgcolor="#999999"><input name="passWord" type="password" value="Password" class="login_text" /></td>
      </tr>
      <tr>
        <td colspan="2" bgcolor="#999999"><div align="center">
          <input type="submit" name="AuthLogin" value="Submit" />
        </div></td>
        </tr>
    </table>

            </form>
            <?        
        }
        
    ?>
    Any Help is apperciated.
    Not to put any pressure on anyone but.. i have till saturday to finish.
    I had this project sprung on me without notice.T'is hard to say no. You know...
    Last edited by PlaGuE; Aug 23rd, 2006 at 11:46 PM.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

Posting Permissions

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



Click Here to Expand Forum to Full Width