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
https://forums.phpfreaks.com/topic/206198-question-regarding-custom-auth-class/
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?

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.