<?php
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php
$user_admin=$_COOKIE["user_admin"];
$jahrgang=$_COOKIE["jahrgang"];
$hs=$_COOKIE["ck_hs"];


if ($jahrgang == ""){ require("jahrgang.php"); exit;} //Wenn man kein Jahrgang ausgew&auml;hlt hat wird die Jahrgangsauswahlseite geladen

// Rechte&uuml;berpr&uuml;fung
$db = dbconnect();
if ($user_admin == ""){ require("index.php"); exit;} //Wenn man nicht angemeldet ist, darf man nicht auf die Seite
$result = $db->query("SELECT 1 FROM stan_admin_rechte, stan_admin_rechte_zuord , stan_admin where stan_admin_rechte.stan_admin_rolle = stan_admin_rechte_zuord.stan_admin_rolle AND stan_admin_rechte_zuord.said = stan_admin.said AND stan_admin.user = '$user_admin' AND stan_admin_rechte_zuord.stan_admin_rolle = 'a_studbear'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende

if (isset($_GET['action']))
   $action = $_GET['action'];
else
   $action = "";

switch($action){
default:

echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
	<script type=\"text/javascript\" src=\"livesearch/ajax.js\"></script>
	<script type=\"text/javascript\" src=\"livesearch/ajax-dynamic-list.js\"></script>
<style type=\"text/css\">
select{
	width:250px;
}



	/* Big box with list of options */
	#ajax_listOfOptions{
		position:absolute;	/* Never change this one */
		width:320px;	/* Width of box */
		height:200px;	/* Height of box */
		overflow:auto;	/* Scrolling features */
		border:1px solid #6487DC;	/* Dark blue border */
		background-color:#FFF;	/* White background color */
		text-align:left;
		font-family		:	verdana, arial;
		z-index:10000;
	}
	#ajax_listOfOptions div{	/* General rule for both .optionDiv and .optionDivSelected */
		margin:1px;
		padding:1px;
		cursor:pointer;
		font-size:0.9em;
	}
	#ajax_listOfOptions .optionDiv{	/* Div for each item in list */

	}
	#ajax_listOfOptions .optionDivSelected{ /* Selected item in the list */
		background-color:#D6DFF7;
		color:#002276;
		font-family		:	verdana, arial;
		font-weight		:	bold;
	}
	#ajax_listOfOptions_iframe{
		background-color:#F00;
		position:absolute;
		z-index:500;
	}
</style>

<title>>Student bearbeiten</title>
</head>
<body onload=\"if(document.beleg)document.beleg.stud.focus();return false;\">
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_top.gif\" valign=\"top\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Student bearbeiten</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td>
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=studbearb"; echo" method=\"POST\" name=\"beleg\">
                      <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"115\">
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"25%\">&nbsp;</td>
                          <td width=\"25%\">
                          <p>&nbsp;
                          </td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\"colspan=\"2\">&nbsp;</td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\" colspan=\"2\">
                          <p align=\"center\"><b>Student wählen</b><br><br>
                          	<input type=\"text\" id=\"stud\" name=\"stud\" value=\"\" onkeyup=\"ajax_showOptions(this,'getWord',event)\" size=\"50\">
				<input type=\"hidden\" id=\"stud_hidden\" name=\"stud_ID\"><!-- THE ID OF the textstelle will be inserted into this hidden input -->
                          </td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          <p>
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          &nbsp;</td>
                          <td width=\"25%\">
                          <p>
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          <input type=\"submit\" value=\"Bearbeiten\" name=\"B1\"></td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          &nbsp;</td>
                          <td width=\"25%\">
                          </td>
                        </tr>                        
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">
                          </td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"25%\">
                          </td>
                          <td width=\"50%\" colspan=\"2\" align=\"center\">&nbsp;</td>
                          <td width=\"25%\">
                          </td>
                        </tr>
                      </table>
                    </form>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
break;
case "studbearb":
$stud = $_POST[stud];
$pos1 = strpos  ($stud, '(')+1;
$pos2 = strpos  ($stud, ')')-$pos1;


$str = substr($stud, $pos1,$pos2);

$str = explode(",",$str);

$mtknr=trim($str[0]);
$uid=trim($str[1]);

setcookie("ck_studbe","");
setcookie("ck_studbe",$uid);

$vert = $_POST[vert];
$adresse = stripslashes( $_POST['Raum'] );
$hinweis = stripslashes( $_POST['hinweis'] );
$beg_std = $_POST['beg_std'];
$beg_min = $_POST['beg_min'];
$beg_sek = '00';




if($_POST[stud] == ''){
  echo "
  <html>
  <head>
  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
  <link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
  <title>Falsches Datum</title>
  </head>
  <body>
  <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Pflichtfelder ausfüllen</span><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Bitte füllen Sie alle Pflichtfelder aus!</p></b>
                    </p>
                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
  </body>
  </html>";
  exit;
}



$db = dbconnect();
$result = $db->query ("SELECT uid
                          FROM stud
                         WHERE mtknr='$mtknr'
                           AND uid='$uid'
                      ");
$row_stud = $result->fetch_array();


if($row_stud[uid] == ''){
  echo "
  <html>
  <head>
  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
  <link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
  <title>Falsches Datum</title>
  </head>
  <body>
  <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Datensatz nicht vorhanden</span><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Es konnte kein Datensatz mit diesen Angaben gefunden werden</p></b>
                    </p>
                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
  </table>
  </body>
  </html>";
  exit;
}



$db = dbconnect();
$bearb_stud = $db->query ("SELECT uid, nachname, vorname, mtknr, stg, poplz, poOrt, poStrasse, AG, Jahrgang, Pwd, Mail, Mail2, durchgefallen
                                  , date_format(Geburtstag, '%d') geb_tag
                                  , date_format(Geburtstag, '%m') geb_mon
                                  , date_format(Geburtstag, '%Y') geb_jahr
                              FROM stud
                             WHERE uid='$uid'");
$stud = $bearb_stud->fetch_array();

echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>>Student bearbeiten</title>
</head>
<body onload=\"if(document.beleg)document.beleg.vorname.focus();return false;\">
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_top.gif\" valign=\"top\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Student bearbeiten</font><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></font></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td>
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=dozbearb1"; echo" method=\"POST\" name=\"beleg\">
                      <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"246\">
                        <tr>
                          <td width=\"40%\">
                          <b>Matrikelnr*:</b>
                          </td>
                          <td width=\"60%\">
                            <input type=\"text\" name=\"mtknr\" value=\"$stud[mtknr]\" size=\"6\">
                          </td>
                        </tr>
                        <tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Vorname*:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"vorname\"  value=\"$stud[vorname]\"size=\"40\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Nachname*:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"nachname\"  value=\"$stud[nachname]\" size=\"40\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Stra&szlig;e:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"strasse\" value=\"$stud[poStrasse]\" size=\"40\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>PLZ:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"plz\"  value=\"$stud[poplz]\" size=\"5\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\">
                          <b>Ort:</b>
                          </td>
                          <td width=\"60%\">
                          <input type=\"text\" name=\"ort\" value=\"$stud[poOrt]\" size=\"40\">
                          </td>
                        </tr>
                        <tr>
                          <td width=\"40%\" valign=\"top\">
                          <b>Studienzweig*:</b><br>
                          </td>
                          <td width=\"60%\" align=\"left\">
                          <select size=\"4\" name=\"zweig\">
                            <option value=\"F\""; if ($stud[stg] == 'F'){echo " selected";} echo ">Finanzverwaltung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"R\""; if ($stud[stg] == 'R'){echo " selected";} echo ">Rentenversicherung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"I\""; if ($stud[stg] == 'I'){echo " selected";} echo ">Innenverwaltung &nbsp;&nbsp;&nbsp;</option>
                            <option value=\"S\""; if ($stud[stg] == 'S'){echo " selected";} echo ">Steuerverwaltung &nbsp;&nbsp;&nbsp;</option>
                          </select>
                          </td>
                        </tr>
                        <tr>
                          <tr>
                          <td width=\"40%\">
                          <b>Geburtsdatum*:</b>
                          </td>
                          <td width=\"60%\">
                            <input type=\"text\" name=\"geb_tag\" value=\"$stud[geb_tag]\" size=\"2\">.<input type=\"text\" name=\"geb_mon\" value=\"$stud[geb_mon]\" size=\"2\">.<input type=\"text\" name=\"geb_jahr\" value=\"$stud[geb_jahr]\" size=\"4\">
                          </td>
                        </tr>
                        <tr>
                          <tr>
                          <td width=\"40%\">
                          <b>AG*:</b>
                          </td>
                          <td width=\"60%\">
                            <input type=\"text\" name=\"ag\" value=\"$stud[AG]\" size=\"1\"> /
                            <input type=\"text\" name=\"jahr\" value=\"$stud[Jahrgang]\" size=\"2\">
                          </td>
                        </tr>

                          <td width=\"40%\">
                          <b>Benutzerkennung:</b>
                          </td>
                          <td width=\"60%\">
                          $stud[uid]
                          </td>
                        </tr>
                        <tr>
                            <td>
                            <b>E-Mail Adresse*:</b>
                            </td>
                            <td>
                            <input type=\"text\" name=\"mail\" value=\"$stud[Mail]\"size=\"40\">
                            </td>
                          </tr>
                        <tr>
                            <td>
                            <b>E-Mail Adresse 2:</b>
                            </td>
                            <td>
                            <input type=\"text\" name=\"mail2\" value=\"$stud[Mail2]\"size=\"40\">
                            </td>
                          </tr>
                          <tr>
                            <td>
                            <b>Durchgefallen:</b>
                            </td>
                            <td>";
                              echo "
                              <input type=\"radio\" value=\"N\" name=\"durchgefallen\"";
                                IF ($stud[durchgefallen] == "N" )
                                  echo " checked";
                                ELSEIF ($stud[durchgefallen] == "" )
                                  echo " checked";
	                          echo ">Nein<br>
                                        <input type=\"radio\" value=\"Y\" name=\"durchgefallen\"";

		                if ($stud[durchgefallen] == "Y") echo " checked";
		                echo ">Ja
                            </td>
                          </tr>
                        <tr>
                            <td>
                            <b>Kennwort neu setzen:</b>
                            </td>
                            <td>
                            <input type=\"text\" name=\"passwort\" size=\"40\">
                            </td>
                          </tr>

                      </table>
                      * = Pflichtfelder
                      <br>
                      <br>
                        <input type=\"submit\" value=\"Abschicken\" name=\"B1\">
                    </form>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

break;
case "dozbearb1":

if ($_POST[vorname] ==  "" or $_POST[mtknr] ==  "" or $_POST[nachname] ==  ""  or $_POST[zweig] ==  "" or $_POST[ag] ==  ""  or $_POST[geb_tag] ==  ""  or $_POST[geb_mon] ==  ""  or $_POST[geb_jahr] ==  "" or $_POST[jahr] == ""  or $_POST[mail] ==  "" ){
echo"
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Eingabefehler</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Eingabefehler</span><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Es m&uuml;ssen mindestens die Pflichtfelder ausgef&uuml;llt werden!</b>
                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>
                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
exit;
} // Ende If

if ($_POST['zweig']== 'F'){ $stgtext ='Finanzverwaltung';}
if ($_POST['zweig']== 'R'){ $stgtext ='Rentenversicherung';}
if ($_POST['zweig']== 'I'){ $stgtext ='Innenverwaltung';}
if ($_POST['zweig']== 'S'){ $stgtext ='Steuerverwaltung';}


if (@checkdate($_POST[geb_mon], $_POST[geb_tag], $_POST[geb_jahr]) == 0) { // checkdate liefert 0 & 1 zur&uuml;ck: 0 wenn Datum falsch, 1 wenn Datum richtig
  echo "
  <html>
  <head>
  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
  <link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
  <title>Falsches Datum</title>
  </head>
  <body>
  <table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
      <tr>
          <td>
          <div align=\"center\">
              <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                  <tr>
                      <td width=\"10\" background=\"../images/box_e1.gif\">
                      <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                      <td width=\"95%\" background=\"../images/box_top.gif\">
                      <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                      <span class=\"sh\">Falsches Datum</span><br>
                      <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                      <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                      <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                  </tr>
                  <tr>
                      <td width=\"1%\" background=\"../images/box_l.gif\">
                      <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td colspan=\"2\"><br>
                      <p align=\"center\">Das Geburtsdatum ist falsch!</p>
                      </p>
                      <p align=\"center\"><a href=\"javascript:history.back()\">
                      <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                      </p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p></p>
                      <p><br>
                      </p>
                      </td>
                      <td width=\"1%\" background=\"../images/box_r.gif\">
                      <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                  </tr>
                  <tr>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                      <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                      <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                      <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                  </tr>
              </table>
          </div>
          </td>
      </tr>
  </table>
  </body>
  </html>";
  exit;
} // Ende Datums&uuml;berpr&uuml;fung


$geburtstag = "$_POST[geb_jahr]-$_POST[geb_mon]-$_POST[geb_tag]";

$db = dbconnect();
$ck_studbe = $_COOKIE["ck_studbe"]; //Cookie in Variable schreiben

if($_POST[passwort] == ''){
  
$sql =  "UPDATE stud SET
         nachname=\"". $_POST['nachname']."\"
       , vorname=\"". $_POST['vorname']."\"
       , poplz=\"". $_POST['plz']."\"
       , poOrt=\"". $_POST['ort']."\"
       , poStrasse=\"". $_POST['strasse']."\"
       , stg=\"". $_POST['zweig']."\"
       , stgtext='$stgtext'
       , AG=\"". $_POST['ag']."\"
       , Geburtstag = '$geburtstag'
       , Jahrgang=\"". $_POST['jahr']."\"
       , mtknr=\"". $_POST['mtknr']."\"
       , Mail=\"". $_POST['mail']."\"
       , Mail2=\"". $_POST['mail2']."\"
       , durchgefallen=\"". $_POST['durchgefallen']."\"
       WHERE uid=\"$ck_studbe\"";
}else{
$pw_neu = md5($_POST[passwort]); // passwort md-5 codieren
$sql =  "UPDATE stud SET
         nachname=\"". $_POST['nachname']."\"
       , vorname=\"". $_POST['vorname']."\"
       , poplz=\"". $_POST['plz']."\"
       , poOrt=\"". $_POST['ort']."\"
       , poStrasse=\"". $_POST['strasse']."\"
       , stg=\"". $_POST['zweig']."\"
       , stgtext='$stgtext'
       , AG=\"". $_POST['ag']."\"
       , Geburtstag = '$geburtstag'
       , Jahrgang=\"". $_POST['jahr']."\"
       , Pwd = '$pw_neu'
       , mtknr=\"". $_POST['mtknr']."\"
       , Mail=\"". $_POST['mail']."\"
       , Mail2=\"". $_POST['mail2']."\"
       , durchgefallen=\"". $_POST['durchgefallen']."\"
       WHERE uid=\"$ck_studbe\"";
}

$sql2 = $db->query ($sql);

if ($sql2)
{

Echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Student bearbeitet</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Student bearbeitet</span><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Die &Auml;nderungen wurden gespeichert!</b>

                    <p align=\"center\"><a href=\"stud_bearb.php\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>

                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>

                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
}else{
echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"../styles_pc.css\" type=\"text/css\">
<title>Student bearbeitet</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"../images/box_e1.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"../images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"../images/box_top.gif\">
                    <img height=\"10\" src=\"../images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Student bearbeitet</span><br>
                    <img height=\"5\" src=\"../images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e2.gif\">
                    <img height=\"40\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"../images/box_l.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Die &Auml;nderungen konnten nicht gespeichert werden!</b>

                    <p align=\"center\"><a href=\"stud_bearb.php\">
                    <img border=\"0\" src=\"../images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>

                    <p>
                    <p>
                    <p>
                    <p>
                    <p><br>

                    </td>
                    <td width=\"1%\" background=\"../images/box_r.gif\">
                    <img height=\"1\" src=\"../images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"../images/box_e3.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"../images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"../images/box_e4.gif\">
                    <img height=\"16\" src=\"../images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
}



} // Ende Action script
?>