-1

I have the following PHP variables which essentials grab some strings found in the URL:

<?php    
$tx = $_GET["tx"];
$amount = $_GET["amount"];
?>

I would like to be able to use these variables as such:

$scope.userUpdatePayment = function(form) {
    var update = Parse.User.current();
    update.set("amount", $amount);
    update.save(null, {
        success: function(update) {
            //success         
        },
        error: function(update, error) {
            //failure 
        }
    });
}
Björn Kaiser
  • 9,882
  • 4
  • 37
  • 57
Jon
  • 119
  • 2
  • 10
  • Beside it is a duplicate to the given question. Why don't you read that values directly from the url in js: [How to get the value from the URL parameter?](http://stackoverflow.com/q/979975/1960455) – t.niese Feb 03 '15 at 17:40
  • for security reasons i would get it using php for user cannot read it, and then use javascript to store it – Jon Feb 03 '15 at 17:44
  • You are passing values that are in the url (and as of that visible to user anyway) from php (server side) to js (client side) to store it again on the server(?). I don't really see why this should make it more secure then reading it directly using javascript to store it. – t.niese Feb 03 '15 at 17:50
  • I am trying this but it doesnt seem to be working var paidId = ; update.set("paidID", paidId); – Jon Feb 03 '15 at 18:27

1 Answers1

-1

Try this

$scope.userUpdatePayment = function(form) {
    var update = Parse.User.current();
    update.set("amount", <?=$amount?>);
    update.save(null, {
        success: function(update) {
            //success         
        },
        error: function(update, error) {
            //failure 
        }
    });
} 
Tunaki
  • 132,869
  • 46
  • 340
  • 423
bharat savani
  • 339
  • 5
  • 18
  • This answer is not appreciably different from [this one](http://stackoverflow.com/a/28307046/19068) from two years ago. It is also vulnerable to XSS attacks. – Quentin Mar 04 '17 at 11:05