Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

PHP Web View Online

<!DOCTYPE html>
<html>
<head>
<meta charest="UTF-8"
<title>my first thing</title>
</head>
<body>
<form>
    <input type="text" name="NUM1" placeholder="NUMBER1">
    <input type="text" name="NUM2" placeholder="NUMBER2">
    <select name="operator">
        <option>NON</option>
        <option>ADD</option>
        <option>subtract</option>
        <option>multiply</option>
        <option>divide</option>
    </select>
    <br>
    <button type="submit" name="submit" value="submit">calculate</button>
</form>
<p>the answer is:</p>
<?php
if (isset($GET_['submit'])){
    $result1=$GET_['NUMB1'];
    $result2=$GET_['NUMB2'];
    $operator=$GET_['operator'];
    switch ($operator) {
        case NON:
            echo "EROOR";
             break;
              case ADD:
            echo $result1 + $result2 ;
            break;
              case subtract:
            echo $result1 - $result2 ;
            break;
              case multiply:
           echo $result1 * $result2 ;
            break;
              case divide:
            echo $result1 / $result2 ;
            break;
    }
}
?>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.