diff --git a/registration-system/config.inc.php b/registration-system/config.inc.php
index 0a036f760ef674e10ddeb7afb2490cbff0c82352..ecfb0215d744cef810e7dca47d552ef50dea17fb 100644
--- a/registration-system/config.inc.php
+++ b/registration-system/config.inc.php
@@ -2,7 +2,7 @@
 // https://repke.eu:8443
 // passwort manu:kuzerPenis666!
 
-$config_verbose_level = 2; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose
+$config_verbose_level = 3; // 0 = nothing, 1 = important, 2 = somewhat important, 3 = detailed verbose
 
 $config_db = array(
     "name" => "fsfahrt",
diff --git a/registration-system/frameworks/commons.php b/registration-system/frameworks/commons.php
index aebab42f026ffbf9684d827527fe3dc8ccc66c86..98ea7ea53795d536a967e7bdd4de38c03b797f42 100644
--- a/registration-system/frameworks/commons.php
+++ b/registration-system/frameworks/commons.php
@@ -20,4 +20,24 @@ function comm_format_date($date){
 
 function comm_get_possible_dates($fid){
     return array("12.03.2014","13.03.2014","14.03.2014");
+}
+
+function comm_isopen_fid($db_handle, $fid){
+    comm_verbose(3,"checking if fid ". $fid . " is open");
+    return $db_handle->has("fahrten", array(
+                                            "AND" => array(
+                                                "fahrt_id"=>$fid,
+                                                "regopen"=>1)));
+}
+
+function comm_generate_key($db_handle, $table, $col, $conditions){
+    again:
+    $bytes = openssl_random_pseudo_bytes(8);
+    $hex   = bin2hex($bytes);
+    comm_verbose(3,"generated hex for test: ".$hex);
+    $conditions[$col] = $hex;
+
+    if($db_handle->has($table, array("AND"=>$conditions))) goto again;
+    comm_verbose(2,"generated hex: ".$hex);
+    return $hex;
 }
\ No newline at end of file
diff --git a/registration-system/index.php b/registration-system/index.php
index 7aa868e96ad7d16d87d5d248e3eeb34c6ac5de2e..463505b160bfd6ad61f98e1425672bd3e482dbbe 100644
--- a/registration-system/index.php
+++ b/registration-system/index.php
@@ -43,10 +43,12 @@ function index_show_content(){
         // --- Formular
         if(isset($_REQUEST['submit'])){ // Formular auswerten
             comm_verbose(1,"Formular bekommen");
-            index_check_form();
-        } elseif(isset($_REQUEST['bid'])){ // Änderungsformular anzeigen TODO: Anmeldung noch offen?
+            $data = index_check_form();
+            if(!is_null($data))
+                index_form_to_db($data);
+        } /*elseif(isset($_REQUEST['bid'])){ // Änderungsformular anzeigen, Anmeldung noch offen?
             index_show_formular($fid, $_REQUEST['bid']);
-        } else {                       // leeres Formular anzeigen
+        } */ else {                       // leeres Formular anzeigen
             index_show_formular($fid);
         }
 
@@ -61,6 +63,13 @@ function index_show_content(){
 
 }
 
+function index_form_to_db($data){
+    global $index_db;
+    $data['version'] = 1;
+    $data['bachelor_id'] = comm_generate_key($index_db, "bachelor", "bachelor_id", array('fahrt_id'=>$data['fahrt_id']));
+    $index_db->insert("bachelor", $data);
+}
+
 /**
  * validates the sent form
  * on failure: repost form with prefilled data and errors
@@ -68,10 +77,17 @@ function index_show_content(){
  *
  */
 function index_check_form(){
-    global $config_studitypen, $config_essen, $config_reisearten;
+    global $config_studitypen, $config_essen, $config_reisearten, $index_db;
     $errors = array();
+    $data   = array();
+
     $fid  = $_REQUEST['fid'];
-    $data = array();
+    $data['fahrt_id'] = $fid;
+    if(!comm_isopen_fid($index_db, $fid)){
+        $errors = array("Ungültige Fahrt!");
+        goto index_check_form_skip;
+    }
+
     $possible_dates = comm_get_possible_dates($fid);
 
     index_check_field('forname', '/^[a-zA-Z]{2,50}$/', $data, $errors, "Fehlerhafter oder fehlender Vorname!");
@@ -88,12 +104,13 @@ function index_check_form(){
     index_check_field('virgin', array("Ja","Nein"), $data, $errors, 'Bitte Altersbereich wählen!');
     index_check_field('comment', "comment", $data, $errors, 'Trollololol');
 
+    index_check_form_skip:
     if(count($errors)>0){
         index_show_errors($errors);
         index_show_formular($fid, NULL, $data);
+        return NULL;
     } else {
-
-        // put in DB
+        return $data;
 
     }