View Full Version : value from javascript to php

09-28-2011, 04:20 AM
Hi guys, i tried searching for solutions regarding an issue i'm facing but i can't seem to understand what others are asking or the solutions given. I'm not sure if its because our codes are different or what.

Basically the problem i'm facing is that i'm trying to allow user to login to my website using facebook, i'm able to retrieve user's facebook username n information but i'm unable to extract them into my php file as the codes are within a script as shown.

appId:'app_id', cookie:true,
status:true, xfbml:true
FB.api('/me', function(user) {
if(user != null) {
var image = document.getElementById('image');
image.src = 'http://graph.facebook.com/' + user.id + '/picture';
var name = document.getElementById('name');
name.innerHTML = user.name
//document.getElementById('username').innerHTML = user.username;
var username = document.getElementById('username');
username.innerHTML = user.username

<fb:login-button perms="email"> Login with Facebook </fb:login-button>
<div align="left">
<img id="image"/>
<div id="name"></div>
<div id="username"></div>

I'm able to get the user's username using 'user.username' within the script but i'm unable to save it in my php login page which i'm gonna use it to store into my database.

From my understanding this can be done either using cookie or a hidden field but i'm not sure how to integrate them into my code.

Hope there's some pros here who can help this noob.. =[