<?php
-require 'nav.inc';
+require 'include/head.inc';
+require 'include/prefs.inc';
+require 'include/common.inc';
+
if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!=""
&& $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
$email = $_POST['email'];
$password = $_POST['password'];
- require 'createdb.inc';
+ if( ! is_numeric($mnumber) ) {
+ block("red", "Mat.nummer has to be numeric!");
+ exit;
+ }
+
+ require 'include/db.inc';
// user already exists //
if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) {
print "<table bgcolor=\"red\">";
print "<tr><th><b><font color=\"white\">user already registered</font></b></th><tr>";
print "</table>";
- break;
+ exit;
}
$db->query("INSERT INTO students (mnumber,firstname,lastname,email,password)
echo "$firstname $lastname was successfully registered.<br>";
// send password-email //
- $lec_lines = file('var/lecture.txt');
- foreach ($lec_lines as $line_num => $line) {
- $lecture[$line_num] = $line;
- }
- $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . trim($lecture[0]) . " " . trim($lecture[1]) . ".\nRemember your password: $password\n\nYours,\nBanana.";
- //$nachricht = wordwrap($nachricht,70);
+ $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ").\nRemember your password: $password\n\nYours,\nBanana.";
$empfaenger = 'niemand@example.com';
$betreff = 'Der Betreff';
$header = 'From: banana@treefish.org' . "\r\n" .
'Reply-To: noreply@treefish.org' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
- mail($email, "Banana Registration: " . trim($lecture[0]) . " " . trim($lecture[1]), $nachricht, $header);
+ mail($email, "Banana Registration: " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ")", $nachricht, $header);
- break;
+ exit;
}
?>