0
<script src="example"></script>
<script>
    var $id = '<?php echo $id; ?>';
    var $linkAmount = '<?php echo $linkAmount; ?>';
    var $actionAmount = '<?php echo $actionAmount; ?>';
    var $deliverLink1 = '<?php echo $deliverLink1; ?>';
    var $deliverLink2 = '<?php echo $deliverLink2; ?>';
    var $deliverFlink = '<?php echo $deliverFlink; ?>';
    var $id = '<?php echo $id; ?>';
    var $uid = '<?php echo $uid; ?>';
</script>

Till now I used this way, to fetch variables via html and then I used them in my external js file. But first, I don't want to have this in my html file, and also I don`t want that people can see the $uid of other people in the html and the deliverflink.

$stmt = $conn->prepare('SELECT userid, action, action1, link1, action2, link2, action3, link3, action4, link4, faction, flink, actionAmount, linkAmount FROM link WHERE id = ?');
$stmt->bind_param('s', $id);
$stmt->execute();
$stmt->bind_result($uid, $action, $action1, $link1, $action2, $link2, $action3, $link3, $action4, $link4, $faction, $flink, $actionAmount, $linkAmount);
$stmt->fetch(); 
$stmt->close();

Also this is my php script. So I WANT, that I can fetch the value of the php variables directly in the .js file

I. gadf
  • 33
  • 4
  • 2
    If you don't want other people to see those values putting them in JS instead of HTML is not gonna change anything – linasmnew Oct 12 '17 at 19:58
  • What you're asking for is **security by obscurity**, which is a bad development principle. Motivated people will always be able to see your frontend code. If you're doing something that people shouldn't be able to see, it should be done on the backend. – Nick Oct 12 '17 at 19:58
  • snapjs, no just for the normal person, it isnt for the security, just for the normal people. I dont care if a few people see it – I. gadf Oct 12 '17 at 20:09

0 Answers0