PHP は JS の前に最初に実行されますが、次の条件付き PHP ステートメントのようにデータが空でない場合、確認ダイアログ (Javascript の確認など) を出力する簡単な方法はありますか?
<?php
if (!empty($data)) {
//data is not empty
//Ideally I want to show a confirmation dialog in this part to the user
//to confirm if the user wants to overwrite the existing data
//If the user confirms
//Overwrite the existing data here
} else {
//data is empty,proceed to other task
//don't show any dialog
}
ユーザーに別のフォームを追加したくありません。JS 確認のような単純な確認ダイアログだけです。または、これに対する PHP の代替関数はありますか? ありがとう。