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.";
      }
  }

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.