Jump to content

php logged in test


vlydon

Recommended Posts

Hi everyone. I'm customizing a social network that's on the Ning platform, which is php based. And I'm kinda new at php. Anyway, I've written a php file that tests if the user is logged in or not, then I call that php using js/ajax to display certain content based on if the user is logged in or not. Well, the js is reading the php and displaying content, but it always displaying the SAME content no matter if they are logged in. I have a feeling the issue is in the php file itself. Here's the entire content of my php file, which is at http://liveon.ning.com/loggedin.php

<?phpif(XN_Profile::current()->isLoggedIn()) {
    echo "true";

} else  {

    echo "false";

}

?>

 

And here's the js that is calling it. No matter how much I play around with it, the second set of content (after the "else") is being displayed whether the user is logged in or not. If not logged in, they should be seeing "you are not logged in."

 

<script type="text/javascript" src="http://liveon.ning.com/swfobject.js">
</script>
<div id="loggedOutOnlyText"></div>
<script language="JavaScript" type="text/javascript">

function processLoggedIn(response) {

    var loggedOutOnlyText = document.getElementById("loggedOutOnlyText");

    if(response == 'false') {

        loggedOutOnlyText.innerHTML = "You are not logged in.";

    } else {

        var so =   new SWFObject('http://api.ning.com/files/bYkSVgwejIwMGF9TcVjavhDgK6zUbLVsIjJ5ryyLeM8kqKUqrgZvlOt2tz6LTCMwSM0WWvV9Dlm-3YWMKyZX8LLdO0Xdob*3/introbanner.swf','mpl','500','350','7');
  so.addVariable('autostart','true');
  so.write('loggedOutOnlyText');


    }

}

function ajax(url, vars, callbackFunction) {

  var request = window.XMLHttpRequest ?

      new XMLHttpRequest() :

      new ActiveXObject("MSXML2.XMLHTTP.3.0");

  request.open("POST", url, true);

  request.setRequestHeader("Content-Type",

                           "application/x-www-form-urlencoded"); 



  request.onreadystatechange = function() {

    if (request.readyState == 4 && request.status == 200)  {

      if (request.responseText) {

          callbackFunction(request.responseText);

      }

    }

  };

  request.send(vars);

}

ajax("/loggedin.php", null, processLoggedIn);


</script>

 

Can't figure out why the site isn't picking up the echo = "false" for when the user is not logged in. See any glaring errors?? Thanks so much!

Link to comment
https://forums.phpfreaks.com/topic/106832-php-logged-in-test/
Share on other sites

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.