<?php
require_once("func_validEmail.php");
require_once("../config/datenbankanbindung.php");

// Get the user id from URL
#$search=htmlspecialchars(mysql_real_escape_string($_GET["search"]));
$search=strtolower($_GET["search"]);
if(validEmail($search)){
 $db = dbconnect();
 $query = $db->query("SELECT * FROM imt_user WHERE lower(mail) = '" .$search."'") or die(mysql_error()); // Change users to the database where you keep your usernames, and likewise with username
 
 list($user_id) = $query->fetch_array();
 $row = $query->fetch_array();
 if(empty($user_id))
 {
 $check = '<span class="correct">Der Benutzer ist verf&uuml;gbar.</span>';
  }
else
 {
 $check = '<span class="wrong">Der Benutzer ist im System bereits vorhanden!</span>';
 }
}else{
 #$check = '<span class="wrong">Ung&uuml;ltiges Mailformat oder Domain ist falsch</span>';
 $check = '';
}

// Echos whether the user exists or not.
echo $check;
?>