Umfragen
test.php
Go to the documentation of this file.
1 <?php
2 /*
3  * test.php
4  *
5  * Copyright 2012 Johannes <jojo@jojo-42>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  *
22  *
23  */
24 
25 require("inc/widget.class.php");
26 
27 
28 
29 
30 $t = new text();
31 $t->name = "text1";
32 $t->pollID = 1;
33 
35 $r->name="film";
36 $r->set_options(array("Star Wars I" => "SW1", "Star Wars II" => "SW2", "Star Wars III" => "SW3" ));
37 $r->pollID = 1;
38 
39 $l = new label();
40 $l->value="Hallo, dies ist eine Testumfrage. Bitte Wähle einen Film aus und schreibe etwas in die Textbox. <br/> Beides sind Pflichtfelder";
41 $l->pollID = 1;
42 
43 if( isset($_POST["go"]) ){
44 
45  $err = array();
46  try{
47  $t->handle_inpt();
48  }catch (requiredException $e){
49  $err[]= $e->getUiMessage();
50  }catch(varException $e){
51  $err[]= $e->getMessage();
52  }
53 
54  try{
55  $r->handle_inpt();
56  }catch (requiredException $e){
57  $err[]= $e->getUiMessage();
58  }catch(varException $e){
59  $err[]= $e->getMessage();
60  }catch (valueException $e){
61  $err[]= $e->getMessage();
62  }
63 
64  if(sizeof($err) > 0){
65  foreach($err as $er){
66  echo "<p class='error'>Fehler: $er</p>";
67  }
68  }else{
69  print "fdjrfuhfdjh";
70  }
71 
72 
73 }
74 
75 echo "<pre>";
76 var_dump($t->value);
77 var_dump($r->value);
78 echo "</pre>";
79 ?>
80 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
81  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
82 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
83 
84 <head>
85  <title>untitled</title>
86  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
87  <meta name="generator" content="Geany 0.21" />
88  <style type="text/css">
89  .error{background-color:#FF4444}
90  </style>
91 </head>
92 
93 <body>
94 
95 <?php
96  echo "<form method='POST'>";
97  $l->display();
98  echo "<br/>";
99  $r->display();
100  echo "<br/>";
101  $t->display();
102  echo "<input type='submit' name='go' />";
103  echo "</form>";
104 ?>
105 
106 </body>
107 
108 </html>