Posted on 13th Sep 2017
I made a simple script which translates a selection of radiation exposures to a estimated amount of bananas. Even though the result is quite basic it was fun to build!
My startingpoint was a very basic calculation script using a HTML form and PHP calculation I came across.
<title>A simple math calculator</title>
Insert two numbers in the next form and hit submit button <br>
<form action="calculation.php" method="post">
Firstnumber: <input name="num1" type="text" /><br>
Secondnumber: <input name="num2" type="text" />
<input type="submit" />
This form gives to option to input two numbers which are defined with a name. After submitting the results are calculated by in a PHP script.
<title>Simple Math With User Input</title>
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$a = $num1 + $num2;
$b = $num1 - $num2;
echo "The sum of the two numbers is ". $a;
echo "The difference of the two numbers is ". $b;
With this as my starting point I managed to create a new form which gives the response on the same page.
<title>A simple banana calculator</title>
Select a radiation exposure and the preferred banana size for it to be expressed in.<br>
<form action="" method="post">
<legend>Dose in bananas</legend>
Type of exposure:<br>
<option value="40">Thorax x-ray</option>
<option value="55">One day visit to Chernobyl</option>
<option value="70">Flying (NYC-London)</option>
<option value="13000">CT Abdomen</option>
Size of banana:<br>
<input type="submit" value="Submit">
$exposure = $_POST['Exposure'];
$banana = $_POST['Banana'];
$a = round ($exposure / $banana);
$b = round (($a/365),2);
echo "Your exposure equals roughly ". $a ." bananas.";
echo "<br/> Or roughly ". $b ." bananas per day for a year.";
The form gives you seven options which al have a rough dose value in micro Sieverts. For of these options are represented as exposure types and three as banana sizes (I wanted to put in something..). After submitting the HTML form a PHP script is run to find the quotient of the exposure dose and the bananas dose ($a). Additionally the amount of banana’s per day over a year is calculated ($b).
The result might not be impressive for experienced coders but I leaned something new anyway ;)