2 require 'include/head.inc';
 
   3 require 'include/prefs.inc';
 
   4 require 'include/common.inc';
 
   7 if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!="" 
 
   8                            && $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
 
  10   $firstname = $_POST['firstname'];
 
  11   $lastname = $_POST['lastname'];
 
  12   $mnumber = $_POST['mnumber'];
 
  13   $email = $_POST['email'];
 
  14   $password = $_POST['password'];
 
  16   if( ! is_numeric($mnumber) ) {
 
  17     block("red", "Mat.nummer has to be numeric!");
 
  21   require 'include/db.inc';
 
  23   // user already exists //
 
  24   if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) {
 
  25     print "<table bgcolor=\"red\">";
 
  26       print "<tr><th><b><font color=\"white\">user already registered</font></b></th><tr>";
 
  31   $db->query("INSERT INTO students (mnumber,firstname,lastname,email,password) 
 
  32         VALUES (\"$mnumber\",\"$firstname\",\"$lastname\",\"$email\",\"$password\")");
 
  34   print "<table bgcolor=\"lightgreen\">";
 
  35     print "<tr><th><b><font color=\"white\">registration successfull</font></b></th><tr>";
 
  38   echo "$firstname $lastname was successfully registered.<br>";
 
  40   // send password-email //
 
  41   $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ").\nRemember your password: $password\n\nYours,\nBanana.";
 
  42   $empfaenger = 'niemand@example.com';
 
  43   $betreff = 'Der Betreff';
 
  44   $header = 'From: banana@treefish.org' . "\r\n" .
 
  45     'Reply-To: noreply@treefish.org' . "\r\n" .
 
  46     'X-Mailer: PHP/' . phpversion();
 
  47   mail($email, "Banana Registration: " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ")", $nachricht, $header);
 
  53 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
  54   <table bgcolor="black">
 
  55     <tr><th><b><font color="white">registration</font></b></th><tr>
 
  60       <th align="left">First name:</th> <th><input type="text" name="firstname"></th>
 
  63       <th align="left">Last name:</th> <th><input type="text" name="lastname"></th>
 
  66       <th align="left">Mat.nummer:</th> <th><input type="text" name="mnumber"></th>
 
  69       <th align="left">Email:</th> <th><input type="text" name="email"></th>
 
  72       <th align="left">Password:</th> <th><input type="text" name="password"></th>
 
  76       <th></th> <th align="right"><input type="submit" name="submit" value="Register"></th>