1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
|
<html>
<head>
<style type="text/css">
<!--
input.error {
background-color: red;
}
-->
</style>
</head>
<body></body>
<?php
// Formular mit Fehlerauswertung
$errorFelder = array();
$error = null;
$felder = array("name", "email", "info");
// hier startet die ueberpruefung von den Eingabe im Formular
if(isset($_POST['ueberpruefung'])) {
$error = false;
foreach($felder as $feld) {
if(empty($_POST[$feld])) {
$error = true;
$errorFelder[$feld] = true;
}
}
}
//
if($error === false) {
echo "Name --- ".$_POST['name'];
echo "<br>";
echo "Email --- ".$_POST['email'];
echo "<br>";
echo "info --- ".$_POST['info'];
} else {
if($error === true)
echo "<b>Es ist ein Fehler aufgetreten</b>";
?>
<center>
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>">
<br>
Name:<br>
<input name="name" type="text" size="25" value="<?php echo htmlentities($_POST['name']);?>"
<?php if(isset($errorFelder['name'])) echo 'class="error"'; ?>> <br>
<br>
Email:<br>
<input name="email" type="text" size="25" value="<?php echo htmlentities($_POST['email']);?>"
<?php if(isset($errorFelder['email'])) echo 'class="error"'; ?>> <br>
<br>
info:<br>
<input name="info" type="textarea" size="25" value="<?php echo htmlentities($_POST['info']);?>"
<?php if(isset($errorFelder['info'])) echo 'class="error"'; ?>> <br>
<br>
<input type="hidden" name="ueberpruefung" value="1">
<input type="submit" name="Tutorial" value="Absenden">
</form>
</center>
<?php
}
?>
</body>
</html>
|