input

    1. count($_GET)=0, count($_POST)=0, count($inp)=0
    2. neither nor: Array ( )
    3. next method get
    4. c3Array ( )
    5. $_FILES Array ( )

    form

    1. radio1 method: get, post
    2. text2:
    3. checkbox 3 method: c3Eins, c3Zwei, c3Drei,
    4. date (html5)
    5. file (braucht enctype="multipart/form-data" in form)
    6. submit, image schickt koordinaten

    Source /home/ch45859/web/wlkl.ch/public_html/inf/css/h07form.php

    <html>
     <!DOCTYPE html>
     <head>
      <title> <?php echo basename(__file__, '.php'); ?> </title>
     </head>
     <body>
    <ol>
    <h1>input </h1>
    <ol>
    <?php
      if (count($_POST) != 0) {
        $inp = $_POST;
        $met = 'post';
      } else {
        $inp = $_GET;
        if (count($_GET) != 0)
            $met = 'get';
        else
            $met = 'neither nor';
        }
     echo '<li> count($_GET)=' . count($_GET) . ', count($_POST)=' . count($_POST) . ', count($inp)=' . count($inp) . '</li>';
     echo '<li>'. $met . ': ' . print_r($inp, true) . '</li>';
     $met = array_key_exists('met', $inp) ? $inp['met'] : ( $met == 'post' ? 'post' : 'get' ) ;
     echo '<li> next method ' . $met    . '</li>';
     if ( array_key_exists('c3', $inp) )
        $c3 = array_flip($inp['c3']);
     else
        $c3 = array();
     echo '<li> c3' . print_r($c3, true) . '</li>';
     echo '<li> $_FILES ' . print_r($_FILES, true) . '</li>';
    ?>
    </ol>
    
    <h1>form </h1>
    <form action="<?php echo basename(__file__); ?>" method="<?php echo $met; ?>" enctype="multipart/form-data" >
    <ol>
    <li>radio1 method: <input type="radio" name="met" value="get" <?php if ($met == 'get') echo 'checked="checked"';?> /> get, 
        <input type="radio" name="met" value="post"<?php if ($met != 'get') echo 'checked="checked"';?>/> post</li>
    <li>text2: <input type="text" name="text2" value="<?php echo array_key_exists('text2', $inp) ? $inp['text2'] : 'enter text2'; ?>" /></li>
    <li>checkbox 3 method: <input type="checkbox" name="c3[]" value="c3Eins" <?php if (array_key_exists('c3Eins', $c3) ) echo 'checked="checked"';?> /> c3Eins, 
        <input type="checkbox" name="c3[]" value="c3Zwei" <?php if (array_key_exists('c3Zwei', $c3) ) echo 'checked="checked"';?> /> c3Zwei, 
        <input type="checkbox" name="c3[]" value="c3Drei" <?php if (array_key_exists('c3Drei', $c3) ) echo 'checked="checked"';?> /> c3Drei, </li>
    <li> date (html5) <input type="date", name="d4"></li>
    <li> file (braucht enctype="multipart/form-data"  in form) <input type="file" name="file"/> 
    <li> submit, image schickt koordinaten <input type="submit" name="submit" value="subAAA"/> 
        <input type="image" src="i01green.jpg" name="submit" value="subBBB"/> 
        <input type="submit" name="submit" value="subCCC"/> </li>  
    </ol>
    
    <?php foreach($_FILES as $nm => $fi) {
        echo '<h1>loaded file ' . $nm . ' => ' . $fi['name'] . '</h1>';
        if ($fi['name'] != '') { 
            echo '<ol>';
            echo '<li> key = name in input => ' . $nm . '</li>';
            foreach ($fi as $ky => $va)
                echo '<li> ' . $ky . ' => ' . $va . '</li>' ;
            echo '<li> contents of ' .  $fi['tmp_name'] . '<hr/>';
            highlight_file($fi['tmp_name']);
            echo '<hr> </li>';
            $trg = "/tmp/tmpUploads___". basename( $fi['name']); 
            if(move_uploaded_file($fi['tmp_name'], $trg)) 
                echo '<li> uploaded ok to '. $trg . '</li>';
            else
                echo '<li> upload error to '. $trg . '</li>';
            echo '</ol>';
        }
    } ?>
     <h1>Source <?php echo __file__; ?> </h1>
    <?php highlight_file(__file__) ?>
     </body>
    </html>