Results 1 to 5 of 5

Thread: login works... but is stupid

  1. #1

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

    login works... but is stupid

    okay i have a login script... now the url link would be index.php?console...

    but i wana do it that way....lol


    anyways heres the code... that i think im having the trouble with. WHich is located in consolefunctions.php
    PHP Code:
    function check_login($user$pass$nRank) {
      global 
    $userinfo;
      
    $result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
      
    $userinfo mysql_fetch_array($result);
      if(
    $userinfo != NULL)
         
    extract($userinfo);

      
    // If the username matches the result in the mysql query and the password is correct
      // return the rank of the user.
      
    if($user == $username && $pass == $password and $username != NULL) {
        if(
    $disabled != 1) {
          if(
    $rank >= $nRank) {
            return 
    1;
          }
          else {
            echo(
    "
                 <table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
      <tr>
        <td height=25 bgcolor=#333333><div align=center>

                
    $fontString
                You are not high enough rank.  <center><br><font size=2 face=verdana><b><a href=index.php?console.php>Click Here to return to console</font></b></center>
        </div></td>
      </tr>
    </table>      "
    );
          }
        }
        if(
    $disabled == 1) {
      
    $result = @mysql_query("SELECT * FROM members WHERE username = \"$user\"");
      
    $row mysql_fetch_array($result);
      
    extract($row);


          echo(
    "
           <table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>
      <tr>
        <td height=25 bgcolor=#333333><div align=center>

            
    $fontString
            You have been disabled.<br><br>
    <font color=#1C86EE size=1 face=verdana>
    $disabled</font>
        </div></td>
      </tr>
    </table>  "
    );
        }
      }
      else {
        if(!
    $user) {

            echo(
    "
                 <table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
      <tr>
        <td height=25><div align=center>

    <b><font color=FF6600>Please Login.</font></b><br><br>
    <p>
      <p>
      <form action=index.php?console method=post>
                <FONT color=#FFFFFF size=2>
                            <b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
                <b>Password:</b>&nbsp; <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='submit' value='submit' name='login'> 
            </div></td>
      </tr>
    </table>"
    );

        }
        else {
            echo(
    "
                 <table width=100% align=center height=4% border=0 cellpadding=3 cellspacing=1>
      <tr>
        <td height=25><div align=center>


    <b><font color=FF6600>Invalid Username or Password</font></b><br><br>
    <font color=FF6600>Error:</font> Invalid information was given<br>
    Please check the email sent to you for your correct Information.
    <p>
      <p>
      <form action=index.php?console method=post>
                <FONT color=#FFFFFF size=2>
                            <b>Username:<b> <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=username name=username size=\"20\"><br>
                <b>Password:</b>&nbsp; <INPUT style=\"border:1px solid #76A5D5; WIDTH: 115px; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff\" type=password name=password size=\"20\"><br><br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type='submit' value='submit' name='login'> 
            </div></td>
      </tr>
    </table>"
    );
        }
      }


    this is the function that uses it.
    PHP Code:
     function consolepages($page) {
     switch(
    $page){ 
     default: 
    if(
    check_login($_COOKIE['cusername'], $_COOKIE['cpassword'], 0)==1) {
     
    profile($_COOKIE['cusername'], $_SERVER['REMOTE_ADDR']);
     
    displayconsole($_COOKIE['cusername']);  
     }
     break; 
     case 
    "change_profile"
     echo
    "Change Profile"
     break; 
    now when they hit login... the code for the cookies are activated in the index.php at the top of page.
    PHP Code:
    if(isset($_POST['login'])){

    $usern $_POST['username'];

    $passw $_POST['password'];

    setcookie("cpassword""$passw",time() + 3600);

    setcookie("cusername""$usern",time() + 3600);


    now when i click login. it asked me to input the stuff again... which is wierd... so plz help.
    Last edited by PlaGuE; Sep 7th, 2005 at 03:57 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.

  2. #2

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

    Re: login works... but is stupid

    ....hehe...bump...bump...
    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.

  3. #3
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: login works... but is stupid

    are you setting the cookies and then trying to read from them in the same run-though of the script?

    try

    PHP Code:
    function consolepages($page) {
    switch(
    $page){
    default:
    if(
    check_login($_SESSION['cusername'], $_SESSION['cpassword'], 0)==1) {
    profile($_SESSION['cusername'], $_SERVER['REMOTE_ADDR']);
    displayconsole($_SESSION['cusername']);  
    }
    break;
    case 
    "change_profile":
    echo
    "Change Profile";
    break; 
    PHP Code:
    if(isset($_POST['login'])){

    $usern $_POST['username'];

    $passw $_POST['password'];

    $_SESSION['cusername'] = $usern;
    $_SESSION['cpassword'] = $passw;
    setcookie("cpassword""$passw",time() + 3600);

    setcookie("cusername""$usern",time() + 3600);

    with this at the top of your script
    PHP Code:
    session_start();
    $_SESSION['cusername'] = $_COOKIE['cusername'];
    $_SESSION['cpassword'] = $_COOKIE['cpassword']; 

  4. #4

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

    Re: login works... but is stupid

    thanks... will try...
    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.

  5. #5

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

    Re: login works... but is stupid

    worked
    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