Jump to content

Help to change login function required please


xriokax

Recommended Posts

Hello All

 

I currently have a function that takes in user input from form fields $email & $password. If all is well the function logs the user in, if not redirects back to the login form.

 

What I require is two things.

 

1) Allow the user to login with either "email" or "username" (entered in the $email form field).

2) Allow the system to have a "master" password and if that is entered with a valid email or user from above then log that user in.

 

Here is my current function, any help is greatly received.

 

Regards

  function loginMember($email,$password,$returnURL){
    
      if ($email != "" && $password != ""){        
        
        $result = mysql_query("SELECT mid,memberid,forename,surname FROM tbl001_member WHERE emailaddress='$email' AND password='".$password."' AND online=1");
        
        if (mysql_num_rows($result) > 0)
        {
            $row = mysql_fetch_row($result);
                        
            $_SESSION["logged_user"] = $row[2]." ".$row[3];
            $_SESSION["logged_id"] = $row[0];
            $_SESSION["logged_memid"] = $row[1];            
            
            session_unregister('wrong_email');
            
            if (isset($_SESSION["logged_user"]))
            {               
                header('Location:'.$returnURL);
                exit;
            }
        }
	else
	{
            session_register('wrong_email');
            $_SESSION['wrong_email'] = $email;
            return "* There is no registered account with typed email & password.";
        }
      }
  else
  {
          session_register('wrong_email');
          $_SESSION['wrong_email'] = $email;
          return "* Please input email and password correctly.";
      }
  }

 

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.