Jump to content

Recommended Posts

I have a "while" statement with a switch.  I've tried embedding a second function but apparently I'm too stoopid to get it to re-reference it.  Which is typical.

 

But I saw this Generator class that has a yield.  Is the yield thing any good?  There were no comments on php.net manual.

MemberRouter.snip.php

To get the required help, it's best to show your relevant code.

 

If your question is how to add that function to your own code...

 

include the file with that function or paste the function say beginning of your php code and outside of any loops

wherever you need to use that function, call on that function

 

 

Example

 

function MemberRouter ($routeme, $hailPostData) {  $Routed = NULL;

    if ($_SESSION['AMember']["isloggedin"] == 'TRUE') {
            if (!empty($hailPostData) && $hailPostData !== 1) {
                $Routed = $hailPostData; include $hailPostData; return $Routed;}
            else {
                $Routed = 1; include 'CKmembers.php'; return $Routed;}
    } else { $Routed = 0;}

    if (isset($_POST['submit'])) {
        if (self::PostData()) {
            if (empty($routeme)) { $routeme = $_POST['submit']; }
        } else {
        $routeme = "routeback"; $Routed = $_SERVER["PHP_SELF"]; include $_SERVER["PHP_SELF"]; return 0;
          }
    }

    if ($_SESSION['AMember']["isloggedin"] == 'TRUE') { include 'CKmembers.php'; return 1;}
        else {
            include 'log.php';
         }

    while (!$out) {
    switch ($routeme)
    {
            case "routeback":
            $Routed = '$_SERVER["PHP_SELF"]'; include $_SERVER["PHP_SELF"]; return 1;
            $out = 1;
            break;

            case "login":
                $ML = self::MemberLogin();
                if ($ML) {
                    $_SESSION['AMember'] = array('isloggedin' => 'TRUR', RID => '', Username => $_SESSION['field']['username'], ipaddress => '', time => '');  //need site/server prob.
                    $routeme = "loggedin"; break;
                }
                if ($ML = 'who') {
                    $Routed = "loginFAILED -- possible miss 1 lo";
                    $routeme = "routeback"; break;
                }
            break;
    }
    }
}
 
//this will run the function, you will need to use your variables as the arguments
echo MemberRouter ($routeme, $hailPostData);

 

Take note that another file named CKmembers.php is being included within the function, most likely is the member sessions script

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.