Re: Calculator beginner issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



在 2016/5/9 2:22, Erwin Noever 写道:
Hello guys,

I am sorry to disturb you.

I followed a tutorial and i am a newbe to php but want to learn.

My calculator doesn't work, i dont see what is wrong.
Please can someone explain what the issue is or give me a hint.
Thank you in advance.
Html Code:

<form method="post" action="calc.php">
     <input type="text" name="nummer1" placeholder="nummer1" />
     <label for="kies">kies</label>
     <select name="reken" id="kies">
         <option>selecteer</option>
         <option value ="plus">+</option>
         <option value ="min">-</option>
         <option value ="delen">÷</option>
         <option value ="maal">x</option>
     </select>
     <input type="number" name="nummer2" placeholder="nummer2" />
     <input type="submit" value="calculeer" />

</form>

php code:

function bereken ()
{
     $nummer1 = $_POST['nummer1'];
     $nummer2 = $_POST['nummer2'];

     switch ($_POST['reken'])
     {
         case "plus":
             $plus = $nummer1 + $nummer2;
             return $plus;
         break;

         case "min":
             $min = $nummer1 - $nummer2;
             return $min;
             break;

         case "delen":
             $deel = $nummer1 / $nummer2;
             return $deel;
             break;

         case "maal":
             $maal = $nummer1 * $nummer2;
             return $maal;
             break;
         default:
             echo "bereken op een andere maniet";
     }
}

     echo "het resultaat is :". bereken();

?>
<br>
<a href="index.html">terug</a>



this code works very good in my pc,

and I did a little modification :

https://daimaduan.com/paste/9a844ec6a68

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux