Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Oliver Haag www.ohcon.de

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

evaluate form fields with php

// contains all types of fields

// of special interest are selection boxes.
// They can return an array.
// Here is a quick evaluation with implode().

   1  
   2  <!-- Formular auswerten (evaluate form)
   3       ********************************** -->
   4  
   5  <?php
   6  $hidden_value_1 = $_POST['hval1'];
   7  $hidden_value_2 = $_POST['hval2'];
   8  
   9  $short_text	= $_POST['stext'];
  10  $password	= $_POST['pwd'];
  11  $long_text	= $_POST['ltext'];
  12  
  13  $selected_option = $_POST['optn'];
  14  $radio_selection = $_POST['radsel'];
  15  
  16  $check_selection = $_POST['checksel'];
  17  $check_text = implode(', ',$check_selection);
  18  ?>
  19  
  20  
  21  
  22  <html><body>
  23  <h1>Kurze Anzeige (show values)</h1>
  24  Versteckte Werte: <?=$hidden_value_1?>, <?=$hidden_value_2?><br>
  25  Kurzer Text und Passwort: <?=$short_text?>, <span style="color: gray;"><?=$password?></span><br>
  26  Langer Text:  <?=$long_text?><br>
  27  Option: <?=$selected_option?><br>
  28  Radio-Auswahl: <?=$radio_selection?><br>
  29  CheckBox-Auswahl: <?=$check_text?>
  30  
  31  <h1>Ein Formular (form)</h1>
  32  
  33  <!-- Das Beispielformular (form example)
  34       ********************************** -->
  35  <form action="form.php" method="post">
  36  
  37  <!-- versteckte Elemente (hidden elements) -->
  38  <input type="hidden" name="hval1" value="Der erste versteckte Wert">
  39  <input type="hidden" name="hval2" value="Der zweite versteckte Wert">
  40  <p>
  41  
  42  <!-- einzeiliges Eingabefeld und Passwortfeld (text fields) -->
  43  Kurzer Text und Passwort <br>
  44  <input type="text" size="32" maxlength="64" name="stext" value="Kurze Textvorbelegung">
  45  <input type="password" size="16" maxlength="16" name="pwd" value="geheim">
  46  </p><p>
  47  
  48  <!-- mehrzeiliges Eingabefeld (text area) -->
  49  Langer Text <br>
  50  <textarea cols="128" rows="4" name="ltext">
  51  Optionale Textvorbelegung (optional text presetting): kann bei
  52  mehrzeiligen Textfeldern lang sein,da genügend Platz vorhanden ist.
  53  </textarea>
  54  </p><p>
  55  
  56  <!-- Auswahlliste mit Vorauswahl (selection list) -->
  57  Option <br> <select name="optn">
  58  <option selected>Die Erste Option</option>
  59  <option>Die zweite Option</option>
  60  <option>Die dritte Option</option>
  61  </select>
  62  </p><p>
  63  
  64  <!-- Radio-Buttons mit Vorauswahl (radio buttons) -->
  65  Radio-Auswahl <br>
  66  <input type="radio" name="radsel" value="first">Die erste Radiowahl<br>
  67  <input type="radio" name="radsel" value="seccond">Die zweite Radiowahl<br>
  68  <input type="radio" name="radsel" value="third" checked> Die dritte Radiowahl
  69  </p><p>
  70  
  71  CheckBox-Auswahl <br>
  72  <input type="checkbox" name="checksel[]" value="chk1" checked>Die erste Checkwahl<br>
  73  <input type="checkbox" name="checksel[]" value="chk2" checked>Die zweite Checkwahl<br>
  74  <input type="checkbox" name="checksel[]" value="chk3">Die dritte Checkwahl
  75  </p><p>
  76  
  77  <!-- Buttons zum Absenden/ Abbrechen (buttons to submit/reset) -->
  78  <input type="submit" value="auswerten">
  79  <input type="reset" value="zurücksetzen">
  80  
  81  </form>
  82  </body></html>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS