Advertisement
pan7nikt

form

Nov 3rd, 2021
930
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.     <head>
  4.         <meta charset="UTF-8">
  5.         <title>PHP</title>
  6.     </head>
  7.     <body>
  8.         <form action="" method="POST">
  9.             <input type="number" name="x">
  10.             <input type="number" name="y">
  11.             <input type="number" name="z">
  12.             <input type="submit" value="oblicz">
  13.         </form>
  14.  
  15.         <h1>Tworzymy stronę z zastosowaniem PHP</h1>
  16.         <?php
  17.         $x=$_POST['x'];
  18.         $y=$_POST['y'];
  19.         $z=$_POST['z'];
  20.  
  21.         if(isset($_POST['x']) && isset($_POST['y']) && isset($_POST['z']))
  22.         {
  23.        
  24.             try
  25.             {
  26.                 if($x+2>=0 && ($x+$y)!=0 && (4+$z/$x+$y) > 0)
  27.                 {
  28.                    
  29.                     $k=sqrt($x + 2)/($y-3) + 2*(sqrt((4+$z)/($x+$y)));
  30.        
  31.                     echo($k);
  32.                 }
  33.                 else
  34.                 {
  35.                    
  36.                     echo("sprawdź poprawność danych");
  37.                 }
  38.             }
  39.             catch(Exception $e)
  40.             {
  41.                 echo("sprawdź poprawność danych");
  42.             }
  43.  
  44.         }
  45.  
  46.  
  47.         ?>
  48.     </body>    
  49. </html>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement