Operations in php [closed]

-2

This is the HTML code

<DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <script type="text/javascript" src="funciones4.js"></script>
  <link rel="stylesheet" type="text/css" href="estilo4.css">
        <title>Botones</title>
</head>

<body bgcolor="transparent">
<div class="index2.1">
    <marquee>ESCOGE UNO PLOX</marquee>
    <!--form name="index2.2" method="POST" id="index2.2"-->
    <center>
        <fieldset>
            <button id="hipot" onclick= "hipotenusa()">H I P O T E N U S A</button><br><br>
            <button id="seno" onclick= "sen()">SEN α </button>
        </fieldset>
    </center>

    <!--/form-->
</div>

</body>
</html>

I have to extract the sine but in PHP through another screen, this I have

<!DOCTYPE html>
<html>
<head>
    <!--sen-->
    <title>formulario2.2</title>
</head>
<body background="https://i.pinimg.com/originals/3a/e9/ac/3ae9acea969ac46cf28ec01cde0ca541.jpg">
    <?php


     $senn = $_REQUEST["senn"];
     $co = $_REQUEST["co"];
     $hip= $_REQUEST["hip"];

        if ($_REQUEST[$senn]= $co / $hip;
        echo "<br>" . "<fieldset>" . "<center>" . "EL SENO ES: " . $senn . "</fieldset>" . "</center>";

        $co = $hip * $senn;
        echo "<br>" . "<fieldset>" . "<center>" . "EL CATETO OPUESTO ES: " . $co . "</fieldset>" . "</center>";

        $hip = $co / $senn;
        echo "<br>" . "<fieldset>" . "<center>" . "LA HIPOTENUSA ES: " . $co . "</fieldset>" . "</center>";


    ?>




    </body>
</html>
    
asked by ally_ pretty 25.04.2018 в 04:17
source

1 answer

-2

I would do it as follows:

  • a form that through the post method sent the values of the variables to be occupied to another php file by means of the action tag
  •                                  Buttons   

    <form action="op.php" method="post">
      ingresa el valor del co
      <input type="text" name="co">
      ingresa el valor de la hp
      <input type="text" name="hp">
      <select name="eleccion" id="">
        <option value="sen">sen</option> 
        <option value="cos">cos</option>
        <option value="tan">tan</option>
      </select>
      <input type="submit">
    </form>
    
    </body>
    </html>
    

    Later in a file that calls op.php, I recover those values with the global variable $ _POST, as follows to operate them

    <?php
    
    $co = $_POST["co"];
    $hp = $_POST["hp"];
    $eleccion = $_POST["eleccion"];
    
    
    if($eleccion === "sen"){
        echo $co / $hp;
    }
    
        
    answered by 25.04.2018 / 05:18
    source