So I am trying to make a simple webpage that takes a users name and desired ticker on one page and fetch data on the second page as part of a school project. For some reason, the POST method is not working when I am trying to pass data. Any help with this would be great. Thanks!
form.php
<html>
<body>
<form action="getdata.php" method="post">
Name: <input type="text" name="name">
Ticker: <input type="text" name="ticker">
<input type="submit">
</form>
</body>
</html>
getdata.html
<html>
<body>
Hello <?php echo $_POST['name']; ?>!<br>
Your ticker is
<?php
echo $_POST["ticker"];
$endpoint = "http://query.yahooapis.com/v1/public/yql";
$ticker = "'".$_POST["ticker"]."'";
$query = urlencode("env 'store://datatables.org/alltableswithkeys';select * from yahoo.finance.quotes where symbol in (".$ticker.")");
$ch = curl_init($endpoint.'?q='.$query. '&format=json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if (curl_error($ch)){
die(curl_error($ch));
}
curl_close($ch);
echo'<pre>';
$result = json_decode($result);
$symbol = $result->query->results->quote->symbol;
print_r($symbol);
?>
</body>
</html>
getdata.html
file must be a php file. Rename it to getdata.php