Martins Revolterd Martins Revolterd - 7 months ago 18
HTML Question

simple php/html calculation page issue

ive been struggling to set up a simple gps conversion page for the last hour. it basically has an input of two numbers, these should be calculated then, and the result should be echo'ed. for some reason it wont work. this is what i got:

<html>

<body>




<form action="#" method="post">
Grad: <input type="text" name="search1" placeholder=" grad ... "/>
Min: <input type="text" name="search2" placeholder=" min ... "/>
<input type="submit" value="Submit" /><input type="hidden" name="doSearch" value="1">
</form>

<?php
if($_POST['doSearch']==1) {
$grad = (int)$_POST['search1'];
$min = (int)$_POST['search2'];
$kord = ($min / 60) + $grad;
return $kord;

}
?>




</body>
</html>


any help would be much appreciated

Answer

return

returns a value at the end of a function or method. return - If called from within a function, the return statement immediately ends execution of the current function

Hence there is no function in your code . You just echo your value and it would work for you as

<?php 
if($_POST['doSearch']==1) {
$grad = (int)$_POST['search1'];
$min = (int)$_POST['search2'];
$kord = ($min / 60) + $grad;
echo $kord;// use echo here
}
Comments