You are on page 1of 2

lectures/5/src/index.

php
1.
2. <!DOCTYPE html>
3.
4. <html>
5.
<head>
6.
<title>C$75 Finance</title>
7.
</head>
8.
<body>
9.
<form action="quote.php" method="get">
10.
<input name="symbol" type="text">
11.
<input type="submit">
12.
</form>
13.
</body>
14. </html>

lectures/5/src/quote.php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.

<?
$s = urlencode($_GET["symbol"]);
$url = "http://download.finance.yahoo.com/d/quotes.csv?s={$s}&f=sl1d1t1c1ohgv&e=.csv";
$handle = fopen($url, "r");
$row = fgetcsv($handle);
fclose($handle);
?>
<!DOCTYPE html>
<html>
<head>
<title>C$75 Finance</title>
</head>
<body>
The current price of <?= htmlspecialchars($_GET["symbol"]) ?> is $<?= $row[1] ?>.
</body>
</html>

You might also like