<script>
FB.api('/me', function(user) {
if(user != null) {
var name = document.getElementById('uid');
uid.innerHTML = user.uid
}
});
</script>
UID: <div id="id"></div>
I'm fetching the user ID and getting it to show by placing it in the element with id="uid" with a script. I copy pasted this code from facebook as I don't understand much of anything, anyhow the problem is I need to retrieve the UID many times in the site. In one particular case I need to set it as a value inserted in MYSQL database.
<?php
mysql_select_db("cyberworlddb", $con);
mysql_query("INSERT IGNORE INTO Badges (UID, Website, Code)
VALUES ('UID','$urlhost[0]','UID$urlhost[0]')");
?>
Is there a way to save the UID in a PHP value like $UID so I can retrieve it easily and add it to the database? Else what would be the best way to do it?
Thanks