How to send a Javascript alert message then refresh the page using ESP8266?

Great day to all of you, I'm using RFID RC522 and EPS8266 to create a basic attendance online system based on the tutorial I found online here, I'm using PHP and Arduino Core as the programming tool, the system is working but how can I send an alert message using javascript when the user successfully logged in and when failed and then refresh the page afterwards:

echo "alert('Successfully Login');";

or if failed:

echo "alert('Unable Login');";

I want to refresh the page after clicking OK button in the alert message of Javascript

This is my code in Arduino Core:

 void sendRfidLog(long cardId) {
  
  if(WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    String postData = "cardid=" + String(cardId) + "&action=insertRfIdLog";
    http.begin("http://192.168.1.6/rfid/log.php");            
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");  
    
    int httpCode = http.POST(postData); 
    String payload = http.getString();
    Serial.println(httpCode);
    Serial.println(payload);
    
    if(payload.equals("success")) {
     digitalWrite(SUCCESS_PIN, HIGH);
    } else {
     digitalWrite(ERROR_PIN, HIGH);
    }
    
    http.end();
  }
}

And this is my code in my PHP page:

function insertRfIdLog() {
    include 'connect.php';
    $cardid = $_POST['cardid'];
    $time = time();
	
    $stmt = $conn->prepare("INSERT INTO `tbllogs`(`cardid`, `logdate`) VALUES (:card, :dt)");
    $stmt->bindParam(":card", $cardid);
    $stmt->bindParam(":dt", $time);
    $stmt->execute();
	
	echo "<script>alert('Successfully Login');<script>"; //This is NOT working as an alert, it only prints in Serial Monitor of arduino
}

Thank you in advance