We mentioned how much thought was needed for our revamped Nimh game to involve an Inline HTML Form Email, and thereby be spurning any Javascript “smarts” already involved, so as to both …
- collaborate and share and involve more than one game player … as well as …
- seeing the graphics of that game there in the body section of the email
… and so, rather than jumping straight into Nimh (ouch! … got burnt!) we are picking …
- a simple PHP game …
- currently involving lots of Javascript “smarts” in its workings …
- not yet involving any Inline HTML Form Email functionality
… and work towards collaborating and sharing via those means. The verdict? Yes, even for “small games” like the changed city_guess.php City Guess Country game (you can read the background to, with PHP City Guess Country Game Primer Tutorial), it is no doddle to think “no Javascript”. It is an exercise that helps you appreciate the power and usefulness of client-side Javascript in web applications. The upside is an improvement of your appreciation of how to pare something down to those smaller “navigatable” HTML form snippets to break a concept into collaborative and sharable parts.
Two new HTML form elements become involved, to make this happen …
- the HTML form method=POST action=’//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php’ … to navigate to Inline HTML Form Email creating PHP helper web application …
<form target=iemail style=display:none; action='//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php' method=POST>
<input type=hidden name=inline value=''></input>
<input type=hidden name=emailto id=emailto value=''></input>
<input type=hidden name=subject id=subject value='City Guess Country Game'></input>
<textarea style=display:none; name=htmlis id=htmlis value=''></textarea>
<input type=submit style=display:none; id=contact value=Email></input>
</form>
… filling in emailto (Email To) and htmlis (Inline HTML Form Email content) in a named HTML iframe element, so as not to have to navigate away from the web page …
<iframe name=iemail src=//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php style=display:none;></iframe>
- the HTML form method=GET action=’https://www.rjmprogramming.com.au/Games/CityGuessCountry/city_guess.php’ shell …
<form target=_top id=cgcform action='https://www.rjmprogramming.com.au/Games/CityGuessCountry/city_guess.php' method=GET>
</form>
… encasing existant HTML City and Country elements
… and on returning to “web browser land” from “email client land” the emailee’s answers contribute to the PHP logic …
$egoes="0";
$escore="0";
$emdef="";
if (isset($_GET['thiscity']) && isset($_GET['ucountry']) && isset($_GET['eanswer'])) {
if ($_GET['ucountry'] == $_GET['eanswer']) {
$egoes="1 Well done! " . str_replace("+"," ",urldecode($_GET['thiscity'])) . " is indeed in " . str_replace("+"," ",urldecode($_GET['eanswer'])) . ".";
$escore="1";
} else {
$egoes="1 Sorry, <a title='Google image search' style=cursor:pointer;text-decoration:underline; onclick=woit(this.innerHTML);>" . str_replace("+"," ",urldecode($_GET['thiscity'])) . "</a> is in " . str_replace("+"," ",urldecode($_GET['eanswer'])) . " but is not in " . str_replace("+"," ",urldecode($_GET['ucountry'])) . ".";
}
if (isset($_GET['emailfrom'])) {
$emdef=str_replace("+"," ",urldecode($_GET['emailfrom']));
}
}
… informing of the user of the “Check” (submit button) of their email dropdown selected Country answer for the City presented to them.
We found that second method=GET was the means by which macOS Mail app and Webmail means of emailing were both supported.
Previous relevant PHP City Guess Country Game Primer Tutorial is shown below.
There is no end to the variety of web applications you can do by seeing what free information is out there, but please don’t disrepect the sources of that information. The source for our information today is the excellent XML files created at Webservices … so … thanks.
Today’s game is deceptively simple but quite dynamic, in the sense that we set aside a web server directory for our game today that we have called “City Guess Country Game” and whatever subset of XML files you have from http://www.webservicex.net/new/Home/Index are dynamically read to be the source of information. Here, for the next level up of dynamism you’d involve an RSS feed perhaps, but, today, we just talk about using what we statically have “plonked” in our directory set aside for the game. The word “plonked” always makes me associate with the ever useful PHP method called glob … yes … glob … and so it is here, because that “globbing” definitely goes on. What you will perhaps be disappointed with today is that we don’t use PHP XML native functionality to process the XML data, and please know we recommend trying these approaches as you see fit, but we find the PHP explode method relatively easy to deploy for scenarios like this where the data form is so predictable, and simple.
Deceptively simple games can sometimes be the best, and find that that interest, or not, relates to what we are interested in ourselves … for me that, in particular, is atlases, geography, the “where” of life … so today’s game interests me as much as it will bore others (no doubt).
We show you PHP source code you could call city_guess.php and a live run link as well.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.