The term "favorite country" implies one entity. So, if there are millions of users logged in at the same time and each user enjoys his/her own session, then at max in a session a user would only see one result, namely his/her favorite country. The sessions are not shared -- more info here.
The OP may wish to consider obtaining each user's favorite country and then store that information in a database. Then one may retrieve the stored data and assign it in the process to an array in order to iterate it and display the various countries (or additionally, one may wish to do some kind of statistical analysis with the data).
In the meantime, here's some basic PHP and HTML code :
<?php
error_reporting(E_ALL);
$fav_country = "";
if (isset($_POST["add"]) && $_POST["add"] === "add") {
if (ctype_print($_POST['country'])) {
$fav_country = $_POST['country'];
};
// code to store fav country in dbf:
}
else
if (isset($_POST["display"]) && $_POST["display"] === "display"){
echo "nothing in database yet :)";
// code to retrieve and display the fav countries stored in dbf:
}
?>
<html>
<head><title>testing</title></head>
<body>
<h1> My Favorite Country </h1>
<form action="" method="POST">
<input type="text" name="country"><br>
<input id="clear" type="reset" name="clear" value="clear">
<input type="submit" name="add" value="add">
<input type="submit" name="display" value="display">
</form>
<div><p>My input: <span><?php echo $fav_country ?></span></p></div>
<script>
var d = document;
d.g = d.getElementById;
var clear = d.g("clear");
clear.onclick = function(){
d.getElementsByTagName("span")[0].textContent="";
};
</script>
</body>
</html>
Some things to note:
1) Never trust input from user. Every POST or GET needs to be checked to make sure the data is what you're expecting, otherwise you could be in for some unpleasant surprises to say the least. I use ctype_print() to permit countries composed of multiple names, such as the United Kingdom.
2) If you're new to PHP, be sure to check out the online manual at http://www.php.net.
3) If you're going to work with HTML, use a validator. The input tag does not have a closing tag -- it stands alone.
Good luck to the OP -- we've all been newbies. But, study coupled with sufficient coding experience can transform a newbie into an expert -- it just takes some work! Also, the greater one's technical knowledge, the better one can formulate feasible technical requirements.