Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Maks
- * Date: 25.05.2016
- * Time: 8:00
- */
- session_start();
- $first_argument = $_POST["first_argument"];
- $second_argument = $_POST["second_argument"];
- $result = 0;
- $action = "";
- if (isset($_POST["plus"])) {
- $action = "+";
- $result = $first_argument + $second_argument;
- }
- elseif (isset($_POST["minus"])) {
- $action = "-";
- $result = $first_argument - $second_argument;
- }
- elseif (isset($_POST["multiply"])) {
- $action = "*";
- $result = $first_argument * $second_argument;
- }
- elseif (isset($_POST["divide"])) {
- $action = "/";
- $result = $first_argument / $second_argument;
- }
- $_SESSION["result"] = $result;
- ?>
- <form action="index2.php" method="post" name="calculator">
- <input type = "text" name="first_argument" style="width:100px;">
- <?php echo $action ?>
- <input type = "text" name="second_argument" style="width:100px;">
- =
- <?php echo $result; ?>
- <br>
- <input type="submit" value="+" name="plus">
- <input type="submit" value="-" name="minus">
- <input type="submit" value="*" name="multiply">
- <input type="submit" value="/" name="divide">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement