programming languages – How to sent a alert mail in php?

I have created a login page to perform a sql injection, whenever the sql injection happens in login page admin should automatically get a alert mail. But I’m getting mail even when the user logged in correctly.

    <!DOCTYPE html>
 <html lang="en" dir="ltr">
<meta charset="UTF-8">
<title>Login form </title>
 <link rel="stylesheet" type="text/css" href="style1.css">
     <div class="box">
     <form  action="insert.php" method="POST">
         <input type="text" name="username" placeholder="">
         <input type="text" name="password" placeholder="Password">
         <input type="submit" name="submit" value="Login">


    $conn = mysqli_connect('localhost:3308','root', '')or die("connection error");
$username =$_POST("username");
$query="SELECT * FROM users WHERE username='$username' AND password='$password'";
    $count = mysqli_num_rows($result);

if($count > 0)
    require 'PHPMailer/PHPMailerAutoload.php';
    $mail = new PHPMailer;

//$mail->SMTPDebug = 4;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = '';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '';                 // SMTP username
$mail->Password = 'secret';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('', 'abc');
$mail->addAddress('');     // Add a recipient
//$mail->addAddress('');               // Name is optional
//$mail->addReplyTo('', 'Information');

//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'sample';
$mail->Body    = 'sample checking';
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {

    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo"<h1> success</h1>";
    echo 'Message has been sent';