Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 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.     echo '<form action="" method="post">';
  16.     echo 'Nazwa:<input type="text" name="nazwa"><br>';
  17.     echo '<input type="submit" name="submit" value="Zaakceptuj"><br>';
  18.     echo '</form>';
  19.     }else{
  20.         $_SESSION['name'] = $_POST['nazwa'];
  21.         echo $_SESSION['name'];
  22.             if(isset($_POST['add']))
  23.             {
  24.                
  25.                 $liczba = $_POST['add_value'];
  26.                 $tab = array();
  27.                 array_push($tab,$liczba);
  28.                
  29.                 for($x=0;$x<count($tab);$x++)
  30.                 {
  31.                     $suma=$tab[$x]+$suma;
  32.                 }
  33.                 $srednia=$suma/count($tab);
  34.                 echo "Suma :"; print_r($suma);
  35.                 echo '<br>';
  36.                 echo "Srednia :"; print_r($srednia);
  37.                 $_SESSION['tab']=$tab;
  38.  
  39.                 }else {
  40.             echo '<form action="" method="post">';
  41.             echo 'Liczba:<input type="int" name="add_value"><br>';
  42.             echo '<input type="submit" name="add" value="Jeszcze jedna liczba">';
  43.             echo '<input type="submit" name="end" value="zakoncz">';
  44.             echo '</form>';
  45.             }
  46.             ?>
  47.     </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement