You don't want to generate SQL queries by concatenating user input to a string. This could result in SQL injection.
You want to parameterize your query. First you declare the structure of your query to MySQL then you bind your parameters and call it to get the result. It is like using a function: you rarely generate it on the fly using your user input. Think of your SQL queries as functions.
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$emailIsValid = false;
// Initialize a query. Note how we replaced the variable by a '?'. This indicates a parameter.
$sql = "SELECT username FROM Servers where email=?";
$query = mysqli_stmt_init($conn);
if (mysqli_stmt_prepare($query, $sql)){
// Declare the user email as first parameter of the query
mysqli_stmt_bind_param($query, "s", $user_info['email']);
// Executes the query
mysqli_stmt_execute($query);
// Bind the result to a variable
mysqli_stmt_bind_result($query, $result);
// Read first result
if(mysqli_stmt_fetch($query)){
// At least one user, so the email exists
$emailIsValid = true;
}
// If we don't need the query anymore, we remove it
mysqli_stmt_close($query);
}
if ($emailIsValid) {
//username exists
}
else
{
//...
}
Check the mysqli docs for more information. Although I would advise you to use PDO instead.