Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="pl">
  6.     <head>
  7.     <meta charset="utf-8">
  8.     <title>S457948</title>
  9.     <meta name="author" content="Wojciech Walis" />
  10.     <meta name="keywords" content="Zad Dom" />
  11.     </head>
  12.     <body>
  13.     <?php
  14.     if(!isset($_POST['submit']))
  15.     {
  16.         $_SESSION['name'] = $_POST['nazwa'];
  17.         echo $_SESSION['name']
  18.             if(isset($_POST['add']))
  19.             {
  20.                
  21.                 $liczba = $_POST['add_value'];
  22.                 $tab = array();
  23.                 array_push($tab,$liczba);
  24.                
  25.                 for($x=0;$x<count($tab);$x++)
  26.                 {
  27.                     $suma=$tab[$x]+$suma;
  28.                 }
  29.                 $srednia=$suma/count($tab);
  30.                 echo "Suma :"; print_r($suma);
  31.                 echo '<br>';
  32.                 echo "Srednia :"; print_r($srednia);
  33.                 $_SESSION['tab']=$tab;
  34.  
  35.             }else
  36.             {
  37.                 echo '<form action="" method="post">';
  38.                 echo 'Liczba:<input type="int" name="add_value"><br>';
  39.                 echo '<input type="submit" name="add" value="Jeszcze jedna liczba">';
  40.                 echo '<input type="submit" name="end" value="zakoncz">';
  41.                 echo '</form>';
  42.             }
  43.     }else{
  44.         echo '<form action="" method="post">';
  45.         echo 'Nazwa:<input type="text" name="nazwa"><br>';
  46.         echo '<input type="submit" name="submit" value="Zaakceptuj"><br>';
  47.         echo '</form>';
  48.         }
  49.        
  50.             ?>
  51.     </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement