所以我試圖做一個簡單的網頁,在一個頁面上使用用戶名和想要的代碼,並在第二頁上獲取數據作爲學校項目的一部分。出於某種原因,當我嘗試傳遞數據時,POST方法不起作用。任何幫助,這將是偉大的。謝謝!PHP Post script does not working
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更改爲getdata.php –
'不工作' - 簡潔,準確且完全無用作爲診斷援助。描述應該發生什麼以及實際發生了什麼。包含任何錯誤消息 - 並確保你已經檢查了你的服務器錯誤日誌。 – 2014-02-23 18:42:24
是getdata.html嗎?因爲你的表單的行爲是getdata.php –