Calculator beginner issue

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

 



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>

[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