<?php
if ( $_GET['send'] == true )
{
$msg['vorname'][1] = "<b>Vorname</b> fehlt<br>";
$msg['vorname'][2] = "<b>Vorname</b> (nur Buchstaben erlaubt)<br>";
$msg['name'][1] = "<b>Name</b> fehlt<br>";
$msg['name'][2] = "<b>Name</b> (nur Buchstaben erlaubt)<br>";
$msg['anschrift'][1] = "<b>Anschrift</b> fehlt<br>";
$msg['plz'][1] = "<b>Postleitzahl</b> fehlt<br>";
$msg['plz'][2] = "<b>Postleitzahlt</b> (5 Zahlen erlaubt)<br>";
$msg['ort'][1] = "<b>Ort</b> fehlt<br>";
$msg['ort'][2] = "<b>Ort</b> (nur Buchstaben erlaubt)<br>";
$msg['user'][1] = "<b>Benutzername</b> fehlt<br>";
$msg['password'][1] = "<b>Passwort</b> fehlt<br>";
$msg['email'][1] = "<b>Emailadresse</b> fehlt<br>";
$msg['email'][2] = "<b>Emailadresse</b> falsch<br>";
# Vorname
if ( ( !preg_match("/^[a-zäöüA-ZÄÖÜ\- ]*$/", $_POST['vorname'], $matches) ) && ( $_POST['vorname'] != "" ) )
{
$error['vorname'] = 2;
}
elseif ( $_POST['vorname'] == "" )
{
$error['vorname'] = 1;
}
# Name
if ( ( !preg_match("/^[a-zäöüA-ZÄÖÜ\- ]*$/", $_POST['name'], $matches) ) && ( $_POST['name'] != "" ) )
{
$error['name'] = 2;
}
elseif ( $_POST['name'] == "" )
{
$error['name'] = 1;
}
# Geburtsdatum
if ( $_POST['geburtsdatum'] == "" )
{
$error['geburtsdatum'] = 1;
}
# Anschrift
if ( $_POST['anschrift'] == "" )
{
$error['anschrift'] = 1;
}
# PLZ
if ( ( !preg_match("/^[0-9]{5}$/", $_POST['plz'], $matches) ) && ( $_POST['plz'] != "" ) )
{
$error['plz'] = 2;
}
elseif ( $_POST['plz'] == "" )
{
$error['plz'] = 1;
}
# Ort
if ( ( !preg_match("/^[a-zäöüßA-ZÄÖÜ\.\- ]*$/", $_POST['ort'], $matches) ) && ( $_POST['ort'] != "" ) )
{
$error['ort'] = 2;
}
elseif ( $_POST['ort'] == "" )
{
$error['ort'] = 1;
}
# Benutzername
if ( $_POST['user'] == "" )
{
$error['user'] = 1;
}
# Passwort
if ( $_POST['password'] == "" )
{
$error['password'] = 1;
}
# E-Mail-Addresse
if ( ( !preg_match("/^[\w\-\.]+@[\w\-\.]+\.[^\d]{2,4}$/", $_POST['email'], $matches) ) && ( $_POST['email'] != "" ) )
{
$error['email'] = 2;
}
elseif ( $_POST['email'] == "" )
{
$error['email'] = 1;
}
}
?>
<HEAD>
<title>Anmelden</title>
<link rel="stylesheet" href="format.css" type="text/css">
</HEAD>
<form method="post" action="add_user.php?send=true">
<table border="0" width="100%"><tr>
<td height="350" align="center" valign="middle">
<table border="0">
<tr>
<td colspan="4" align="center" valign="middle" class="submit">
<img src="images/submit.png"></img>
</td>
<tr>
<td align="left" class="submit"><b>Vorname:</b></td>
<td class="submit">
<select name="geschlecht" value="<?=$_POST['geschlecht']?>" size="1">
<option>
<option>Herr
<option>Frau
</select>
<input class="inp260<?=$error['vorname'] != "" ? "error" : ""?>" type="text" name="vorname" value="<?=$_POST['vorname']?>" size="19"></td>
<td align="left" class="submit"><b>Benutzername:</b></td>
<td class="submit"><input class="inp260<?=$error['user'] != "" ? "error" : ""?>" type="text" name="user" value="<?=$_POST['user']?>" size="30"></td>
<tr>
<td align="left" class="submit"><b>Name:</b></td>
<td class="submit"><input class="inp260<?=$error['name'] != "" ? "error" : ""?>" type="text" name="name" value="<?=$_POST['name']?>" size="30"></td>
<td valign="top" align="left" class="submit"><b>Passwort:</b></td>
<td class="submit"><input class="inp260<?=$error['password'] != "" ? "error" : ""?>" type="password" name="password" value="<?=$_POST['password']?>" size="30"></td>
<tr>
<td align="left" class="submit"><b>Geburtsdatum:</b></td>
<td class="submit">
<select name="geburtsdatum_tag" value="<?=$_POST['geburtsdatum_tag']?>" size="1">
<option>
<option>01
<option>02
<option>03
<option>04
<option>05
<option>06
<option>07
<option>08
<option>09
<option>10
<option>11
<option>12
<option>13
<option>14
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>24
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
</select>
<b>.</b>
<select name="geburtsdatum_monat" value="<?=$_POST['geburtsdatum_monat']?>" size="1">
<option>
<option>01
<option>02
<option>03
<option>04
<option>05
<option>06
<option>07
<option>08
<option>09
<option>10
<option>11
<option>12
</select>
<b>.</b>
<input name="geburtsdatum_jahr" size="4" value="<?=$_POST['geburtsdatum_jahr']?>" maxlength="4">
</td>
<td valign="top" align="left" class="submit"><font color="#E6E6FA">(Wiederholen)</font></td>
<td class="submit"><input type="password" name="password2" value="<?=$_POST['password2']?>" size="30"></td>
<tr>
<td align="left" class="submit"><b>Anschrift:</b></td>
<td class="submit"><input class="inp260<?=$error['anschrift'] != "" ? "error" : ""?>" type="text" name="anschrift" value="<?=$_POST['anschrift']?>" size="30"></td>
<td valign="top" align="left" class="submit"><b>Emailadresse:</b></td>
<td class="submit"><input class="inp260<?=$error['email'] != "" ? "error" : ""?>" type="text" name="email" value="<?=$_POST['email']?>" size="30"></td>
<tr>
<td align="left" class="submit"><b>PLZ, Ort:</b></td>
<td class="submit"><input class="inp260<?=$error['plz'] != "" ? "error" : ""?>" type="text" name="plz" value="<?=$_POST['plz']?>" size="5" maxlength="5"> <input class="inp260<?=$error['ort'] != "" ? "error" : ""?>" name="ort" value="<?=$_POST['ort']?>" size="20"></td>
<td valign="top" align="left" class="submit"><font color="#E6E6FA">(Wiederholen)</font></td>
<td class="submit"><input type="text" name="email2" value="<?=$_POST['email2']?>" size="30"></td>
<tr>
<td colspan="4" align="right" valign="top" class="submit">
<input type="submit" name="anmelden" value="Anmelden" class="button">
</td>
</table>
</td>
<td height="350" align="left" valign="middle">
<?php
if ( is_array($error) )
{
echo "<span style='color: #FF0000; font-weight: bold;'>";
echo "Folgende Fehler sind aufgetreten:";
echo "</span>";
}
?><br><br>
<?=$error['vorname'] != "" ? $msg['vorname'][$error['vorname']] : ""?>
<?=$error['name'] != "" ? $msg['name'][$error['name']] : ""?>
<?=$error['anschrift'] != "" ? $msg['anschrift'][$error['anschrift']] : ""?>
<?=$error['plz'] != "" ? $msg['plz'][$error['plz']] : ""?>
<?=$error['ort'] != "" ? $msg['ort'][$error['ort']] : ""?>
<?=$error['user'] != "" ? $msg['user'][$error['user']] : ""?>
<?=$error['password'] != "" ? $msg['password'][$error['password']] : ""?>
<?=$error['email'] != "" ? $msg['email'][$error['email']] : ""?>
</td>
</tr></table>
</form>
<?php
if (!isset($_POST['anmelden'])) {
include('submit.php');
exit; }
include('config.php');
$_POST['geburtsdatum'] = $_POST['geburtsdatum_tag'].'.'.$_POST['geburtsdatum_monat'].'.'.$_POST['geburtsdatum_jahr'];
$_POST['geschlecht'] = ( $_POST['geschlecht'] == 'Herr' ? 'männlich' : 'weiblich' );
$sql = "INSERT INTO user (vorname, name, geburtsdatum, geschlecht, anschrift, plz, ort, user, password, email)
VALUES ('". $_POST['vorname']."', '". $_POST['name']."', '". $_POST['geburtsdatum']."', '". $_POST['geschlecht']."', '". $_POST['anschrift']."', '". $_POST['plz']."', '". $_POST['ort']."', '". $_POST['user']."', '". $_POST['password']."', '". $_POST['email']."')";
mysql_query($sql) or die(error_reporting());
echo"<meta HTTP-EQUIV='refresh' CONTENT='0; URL=submitted.html'>
";
?>