Hi, I created a simple script that converts miles to kilometer. I added it to an HTML file and it works fine, but when I load the page (and there is nothing to convert) it gives me an error:
So basically what I want is to display nothing on page load or if there is nothing in the input field. Here is my code:
<h3 class="section-heading">Convert Miles to Kilometer II.</h3>
<hr class="primary">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" style="margin-top: 20px;">
<p>Add Miles:
<input type="text" class="form-control" placeholder="miles" name="mile" size="2" />
</p>
<p>
<input type="submit" class="btn btn-primary" value="Submit" />
</p>
</form>
<?php
$miles = $_POST['mile']; //This is line 130
// How many km is one mile?
$onemile = 1.609344;
$totalkm = $miles * $onemile;
print "<p>$miles miles is $totalkm kilometer.</p>";
?>
Thanks in advance