×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Calling methods in the correct order, and once the conditions.

Calling methods in the correct order, and once the conditions.

Calling methods in the correct order, and once the conditions.

(OP)
Hello,

I'm starting with object-oriented programming and I have the problem that I do not know how to efficiently manage captured with methods.

For example:

CODE --> php

class logowanie {
 
public function valid_login_name() {
 
    $username = $_GET['username'];  
  $login_name = 'd56b6asdsada53855679cb1d252da';
 
      if(md5($username) === $login_name ){
    echo "extra";
 } elseif(md5($username) !== $login_name
         && !empty($username)   ){
    echo "błedny login";
 
    } elseif(md5($username) == null) {
        echo "nie podales loginu";
 
    } 

I Checks if the given login is the same as that stored in the variable.
I know that I can refer to it by, for example:

CODE --> php

$login= new logowanie();
 $login->valid_login_name(); 

I have also:

CODE --> php

class pozalogowaniu {
 
       public function afterloggin(){
       header("Location: http://www.example.com/");
    }
  } 
And now my question in the style of dump question. How to do it when I want to show the method "afterloggin" only if the method valid_login_name () returns the result from the first condition?

RE: Calling methods in the correct order, and once the conditions.

Technically, your valid_login_name() function doesn't really return anything. It echos out some text to screen.

So the first thing would be to actually make it return something. Other than that, you can still use IF conditions to check the results of your functions outside of classes.

CODE

class logowanie {
 
public function valid_login_name() {
 
    $username = $_GET['username'];  
  $login_name = 'd56b6asdsada53855679cb1d252da';
 
      if(md5($username) === $login_name ){
    return "extra";
 } elseif(md5($username) !== $login_name
         && !empty($username)   ){
   return "błedny login";
 
    } elseif(md5($username) == null) {
        return "nie podales loginu";
 
    } 

Then you can simply just issue IF conditionals to run other functions.

CODE

if($login->valid_login_name()=='extra')
{
do something...
}


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close