2 require 'include/head.inc';
 
   3 require 'include/prefs.inc';
 
   5 if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!="" 
 
   6                            && $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
 
   8   $firstname = $_POST['firstname'];
 
   9   $lastname = $_POST['lastname'];
 
  10   $mnumber = $_POST['mnumber'];
 
  11   $email = $_POST['email'];
 
  12   $password = $_POST['password'];
 
  14   require 'include/db.inc';
 
  16   // user already exists //
 
  17   if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) {
 
  18     print "<table bgcolor=\"red\">";
 
  19       print "<tr><th><b><font color=\"white\">user already registered</font></b></th><tr>";
 
  24   $db->query("INSERT INTO students (mnumber,firstname,lastname,email,password) 
 
  25         VALUES (\"$mnumber\",\"$firstname\",\"$lastname\",\"$email\",\"$password\")");
 
  27   print "<table bgcolor=\"lightgreen\">";
 
  28     print "<tr><th><b><font color=\"white\">registration successfull</font></b></th><tr>";
 
  31   echo "$firstname $lastname was successfully registered.<br>";
 
  33   // send password-email //
 
  34   $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ").\nRemember your password: $password\n\nYours,\nBanana.";
 
  35   $empfaenger = 'niemand@example.com';
 
  36   $betreff = 'Der Betreff';
 
  37   $header = 'From: banana@treefish.org' . "\r\n" .
 
  38     'Reply-To: noreply@treefish.org' . "\r\n" .
 
  39     'X-Mailer: PHP/' . phpversion();
 
  40   mail($email, "Banana Registration: " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ")", $nachricht, $header);
 
  46 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
  47   <table bgcolor="black">
 
  48     <tr><th><b><font color="white">registration</font></b></th><tr>
 
  53       <th align="left">First name:</th> <th><input type="text" name="firstname"></th>
 
  56       <th align="left">Last name:</th> <th><input type="text" name="lastname"></th>
 
  59       <th align="left">Mat.nummer:</th> <th><input type="text" name="mnumber"></th>
 
  62       <th align="left">Email:</th> <th><input type="text" name="email"></th>
 
  65       <th align="left">Password:</th> <th><input type="text" name="password"></th>
 
  69       <th></th> <th align="right"><input type="submit" name="submit" value="Register"></th>