I need to show json data from dynamic url in my website. When visitor make input which is his loyalty card number that number is added to url as suffix. That url is url that contains his details related to loyalty program (points he earned so far etc.).
My code:
<form action="" method="get">
<input type="text" id="unos" name="card" value = ""><br><br>
<input type="submit" name="submit" value="Provjeri bodove">
</form>
<?php
$card = $_GET["card"];
$url='SERVER_URL_HERE/cardcheck/testAlsLoyalty.php?card= <?php echo $card; ?> ';
$json = file_get_contents($url);
$jo = json_decode($json);
echo $jo->user;
echo $jo->card;
echo $jo->rezultat;
echo $jo->bodova;
echo $jo->raspolozivo;
?>
What I got so far is that this code add input as suffix to url of my website, and if I put url of json website as form action value visitor is taken to json website where he can see data. But I want to load data from that url at my website (html or php) after he type card number.
Thank you in advance
<?php echoin?card= <?php echo $card; ?> ', just use?card=' . $card;$_GET["card"]will (probably) not be set, make sure it is set before you execute your PHP code