Jump to content

[SOLVED] can anyone see anything wrong with this function ?.


jamesxg1

Recommended Posts

Hiya peeps,

 

Can anyone see a problem with this function because it is suppose to re-direct me but it isnt,

 

      function Login($lusername, $lpassword) {
                  
          $this->lusername = mysql_real_escape_string(addslashes($lusername));
          $this->lpassword = mysql_real_escape_string(addslashes(md5($lpassword)));
          
          $this->LoginQ = "SELECT * FROM `members` WHERE username = '$this->lusername' AND password = '$this->lpassword'";
          $this->LoginR = mysql_query($this->LoginQ) or die (mysql_error());


          if(mysql_num_rows($this->LoginR) == '1') {
           
              while($fetch =  mysql_fetch_array($this->LoginR)) { 
                  
                  if($fetch['sus'] == '0') {

                                     session_start();
                            $_SESSION['username'] = $this->lusername;
                            $_SESSION['id'] = $fetch['id'];
                            $_SESSION['firstname'] = $fetch['firstname'];

                             echo '<META HTTP-EQUIV="Refresh" CONTENT="5"; URL="html-redirect.html">';
                  } else {
                              echo "Sorry but the account you are trying to access is suspended, Please try again."; 
                                 
                             }          
              }
              
          } else {
              
          echo "Sorry but the account you are trying to access is non existant, Please try again."; 
              
          }
    
    
      }
        

error_reporting(E_ALL);
ini_set('display_errors', 1);

 

Add that at the top of the script.

 

Why are you calling session start in every method?

If you need to make a call of more than one method per page then you are calling session_start() multiple times...

 

Also, you dont need to addslashes to an md5 encryption. Data is encrypted into alpha-numeric chars anyway with md5.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.