我一直在试图弄清楚如何对我的页面进行编码,以便在我的表单中输入答案时,它会通过谷歌地图 API 搜索该答案。我似乎无法正确编码,对于我如何实现目标的任何帮助将不胜感激!谢谢。
<head>
<!-- This is my first trashy online quiz! -->
<title>Extra Quiz Information</title>
</head>
<body>
<h1> More about your quiz results!</h1>
<?php
if (isset($_COOKIE['visit_id'])){
$visit_id = $_COOKIE['visit_id'];
$all_variables = json_decode(file_get_contents("/var/www/html/data/$visit_id.json"), TRUE);
//var_dump ($all_variables);
echo "<p>";
echo "Our results show that when you took the quiz: What Environment Suits You? on "; echo $all_variables['timestamp'];
echo ", <br>you expressed that your favorite place to be in the whole world was: "; echo $all_variables['answer1'];
echo "</p>";
$google_map_stuff = json_decode(file_get_contents echo <a href="http://maps.googleapis.com/maps/api/geocode/json?address=', urlencode($all_variables['answer1'])">, TRUE);
echo $google_map_stuff["results"][0]["types"][0];
//var_dump($google_map_stuff);
} else {
echo "You have not yet taken the quiz titled: What Environment Suits You?<br>
Please "; echo '<a href="roate1-form.html">take it now</a>'; echo " and then return to this page after you have finished.";
}
?>
</body>