Jump to content

question regarding custom auth class


RopeADope

Recommended Posts

The class:

   class Auth{      
      function validate_login($user,$pass){
         if(ctype_alnum($user)){
            return true;
         }else{
            return false;
         }
      }
   }

 

Q1: (new to OOPHP) As you can see, I just have it checking an input to make sure it contains only alphanumeric characters.  My question is, how do I work with the returned result from the if() statement(if at all possible)?  I basically want to have an automatic denial followed by a kickback to the login screen if the if() statement returns false.  My assumption is I should have a class/function somewhere called "location" that I can call to redirect to different pages and such.  Thougts?

Link to comment
Share on other sites

You question is quite ambiguous,

so my answer is

$user = "";
$pass = "";
if(Auth::validate_login($user,$pass)){
  header("Location: Failed.html");
}

 

What does the "::" do?  Also, I plan to have a function under the Auth class that calls another class with a query method to check the $user and $pass against a database.  Will I still be able to do that using your method?

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.