javascript - Send data obtained from facebook with form -


i trying send data php page html page. data acquired javascript variable.

scenario: trying create facebook login page. acquired data fb script , want send name php page. here sample of code:

obtain name fb script:

function testapi() { console.log('welcome!  fetching information.... '); fb.api('/me', function(response) {  var vv=response.name;     console.log('successful login for: ' + response.name);     document.getelementbyid('status').innerhtml = 'thanks logging in, ' + vv + '!'; }); 

variable vv contains value of name.

i try send this form:

<form method="post" action="sample.php" id="form1">     <input type="hidden" name="field1" value="<?php echo $vv; ?>" />     <input type="hidden" name="field2" value="bar" />      <a href="sample.php" onclick="document.getelementbyid('form1').submit(); return false;">go home</a> </form> 

i try display data in sample.php:

<?php echo $_post["field1"]; ?> 

i think form missing something.

javascript variables different php variables. need put login input value , submit form javascript in order variable in sample.php. besides, don't know how javascript code works brackets. here's how think code should go:

<form method="post" action="sample.php" id="form1">     <input type="hidden" name="field1" id="responsename" />     <input type="hidden" name="field2" value="bar" />       <a href="sample.php" onclick="document.getelementbyid('form1').submit(); return false;">go home</a> </form> 

note put id parameter on input.

function testapi() {     fb.api('/me', function(response) {          var input = document.getelementbyid('responsename');         input.value = response.name;         document.getelementbyid('form1').submit();     } } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -