Web lists-archives.com

[PHP] Re: Calculator beginner issue

在 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 value ="plus">+</option>
         <option value ="min">-</option>
         <option value ="delen">÷</option>
         <option value ="maal">x</option>
     <input type="number" name="nummer2" placeholder="nummer2" />
     <input type="submit" value="calculeer" />


php code:

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

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

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

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

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

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

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

this code works very good in my pc,

and I did a little modification :


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