Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>sumar y restar</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <link rel="stylesheet" href="./styles/css/bootstrap.min.css">
- <link rel="stylesheet" href="./styles/js/bootstrap.min.js">
- <link rel="stylesheet" href="./styles/js/jquery-3.2.1.min.js">
- <link rel="stylesheet" href="./styles/js/popper.min.js">
- </head>
- <body>
- <div class="container">
- <div class="row">
- <div class="col">
- <!-- formulario -->
- <form action="sumaresta.php" method="post">
- <div class="form-group">
- <label for="num1">Numero 1</label>
- <input type="text" name="num1" id="num1" class="form-control">
- </div>
- <div class="form-group">
- <label for="num2">Numero 2</label>
- <input type="text" name="num2" id="num2" class="form-control">
- </div>
- <div class="form-group">
- <select name="operacion" id="operacion">
- <option value="suma">Suma</option>
- <option value="resta">resta</option>
- </select>
- </div>
- <div class="form-group">
- <input type="submit" value="enviar" name="enviar">
- </div>
- </form>
- </div>
- </div>
- <div class="row">
- <div class="col">
- <?php
- if (isset($_POST['enviar'])) {
- $num1 = $_POST['num1'];
- $num2 = $_POST['num2'];
- $operacion = $_POST['operacion'];
- function suma($num1,$num2){
- $resultado = $num1 + $num2;
- return $resultado;
- }
- function resta($num1,$num2){
- $resultado = $num1 - $num2;
- return $resultado;
- }
- if ($operacion == "suma") {
- echo suma($num1,$num2)."<br>";
- }else{
- echo resta($num1,$num2)."<br>";
- }
- }else{
- echo "no hay datos";
- }
- $solsuma = suma($num1,$num2);
- $solresta = resta($num1,$num2);
- echo "el resultado de la operacion si es una suma es $solsuma <br>";
- echo "el resultado de la operacion si es una resta es $solresta";
- ?>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement