I can’t verify if there is a duplicate email in my local db. When I register for the first time it’s working and the second time I got an error

And I know my error is due to email adress because when I submit a new user to the form, it’s working well but when I change all the informations except the email adress I got the error 500 Internal Server Error

My code for register

<?php

include 'DbConnect.php';
$objDb = new DbConnect;
$conn = $objDb->connect();

$data = json_decode(file_get_contents('php://input')) ;

$first_name = $data->first_name;
$name = $data->name;
$email = $data->email;
$password = $data->password;
$password_confirm = $data->password_confirm;


$password_hash = password_hash($password, PASSWORD_DEFAULT);


$method = $_SERVER['REQUEST_METHOD'];

switch($method){
    case "POST":

        $sql = "INSERT INTO register(name, first_name, email, password_hash) VALUES ('$name', '$first_name', '$email', '$password_hash')";
        $stmt = $conn->prepare($sql);

        if($stmt->execute()){
            $response = ['status' => 1, 'message' => 'Record created succesfully. '];
        }else{
            $response = ['status' => 0 , 'message' => 'Failed to create record. '];
        }

        echo json_encode($response);
        break;
}
?>