0

I'm trying to use the Fb PHP SDK to execute different Js document.getElementById innerHTML functions, depending on whether the user is logged in to Fb or not. For some reason the function won't work for me. I know my API connection is successful, and Javascript can be inserted here, as I can call alternative alert functions ("you are logged in" :you are not logged in") in this way. But the getElementById function won't work. I've tried moving the script to the body etc, nothing working.

Any ideas? It's probably a rookie question, but I'd love it if there was a simple solution! Here's the essential code below...

<?php if ($user_profile) { ?>
	<script>
		document.getElementById('test1').innerHTML = "<p>You ARE logged in</p>";

	</script>
	<?php } else { ?>
		<script>
			document.getElementById('test1').innerHTML = "You are NOT logged in";
		</script>
	<?php } ?>

	  </head>

	  <body>

	<div id="test1">
	</div>
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jmichae3
0

I'm trying to use the Fb PHP SDK to execute different Js document.getElementById innerHTML functions, depending on whether the user is logged in to Fb or not. For some reason the function won't work for me. I know my API connection is successful, and Javascript can be inserted here, as I can call alternative alert functions ("you are logged in" :you are not logged in") in this way. But the getElementById function won't work. I've tried moving the script to the body etc, nothing working.

Any ideas? It's probably a rookie question, but I'd love it if there was a simple solution! Here's the essential code below...

<?php if ($user_profile) { ?>
	<script>
		document.getElementById('test1').innerHTML = "<p>You ARE logged in</p>";

	</script>
	<?php } else { ?>
		<script>
			document.getElementById('test1').innerHTML = "You are NOT logged in";
		</script>
	<?php } ?>

	  </head>

	  <body>

	<div id="test1">
	</div>

not knowing the sdk, your js and PHP code looks golden. but as to whether it actually works with the fb sdk or not, that's another question.
why don't you check isset() to see if $profile is even a variable that exists?
also, I saw this page:
http://stackoverflow.com/questions/7890779/get-facebook-user-id-username-to-fetch-profile-picture-without-facebook-sdk-php

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.