2 require 'include/head.inc';
 
   4 if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!="" 
 
   5                            && $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
 
   7   $firstname = $_POST['firstname'];
 
   8   $lastname = $_POST['lastname'];
 
   9   $mnumber = $_POST['mnumber'];
 
  10   $email = $_POST['email'];
 
  11   $password = $_POST['password'];
 
  13   require 'include/db.inc';
 
  15   // user already exists //
 
  16   if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) {
 
  17     print "<table bgcolor=\"red\">";
 
  18       print "<tr><th><b><font color=\"white\">user already registered</font></b></th><tr>";
 
  23   $db->query("INSERT INTO students (mnumber,firstname,lastname,email,password) 
 
  24         VALUES (\"$mnumber\",\"$firstname\",\"$lastname\",\"$email\",\"$password\")");
 
  26   print "<table bgcolor=\"lightgreen\">";
 
  27     print "<tr><th><b><font color=\"white\">registration successfull</font></b></th><tr>";
 
  30   echo "$firstname $lastname was successfully registered.<br>";
 
  32   // send password-email //
 
  33   $lec_lines = file('var/lecture.txt');
 
  34   foreach ($lec_lines as $line_num => $line) {
 
  35     $lecture[$line_num] = $line;
 
  37   $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . trim($lecture[0]) . " " . trim($lecture[1]) . ".\nRemember your password: $password\n\nYours,\nBanana.";
 
  38   //$nachricht = wordwrap($nachricht,70);
 
  39   $empfaenger = 'niemand@example.com';
 
  40   $betreff = 'Der Betreff';
 
  41   $header = 'From: banana@treefish.org' . "\r\n" .
 
  42     'Reply-To: noreply@treefish.org' . "\r\n" .
 
  43     'X-Mailer: PHP/' . phpversion();
 
  44   mail($email, "Banana Registration: " . trim($lecture[0]) . " " . trim($lecture[1]), $nachricht, $header);
 
  50 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
  51   <table bgcolor="black">
 
  52     <tr><th><b><font color="white">registration</font></b></th><tr>
 
  57       <th align="left">First name:</th> <th><input type="text" name="firstname"></th>
 
  60       <th align="left">Last name:</th> <th><input type="text" name="lastname"></th>
 
  63       <th align="left">Mat.nummer:</th> <th><input type="text" name="mnumber"></th>
 
  66       <th align="left">Email:</th> <th><input type="text" name="email"></th>
 
  69       <th align="left">Password:</th> <th><input type="text" name="password"></th>
 
  73       <th></th> <th align="right"><input type="submit" name="submit" value="Register"></th>