私はオンラインでフォームを作成しました。ユーザーがsubmitをクリックすると、フォームでエラー(つまり、フィールドがない)をチェックします。現時点では、フィールドを1つずつチェックするフォームがあり、エラーが発生するとすぐにフィールドの残りの部分をチェックせずに終了します。エラーをチェックするif文をすべて1つにまとめる方法はありますか?ここで PHPフォーム - エラーチェック
はコードである//Code to check that the Student Name field is completed
if(empty($_POST['studentName']))
{
$studentNameError = "You did not enter the student name Wank";
//echo "<h3> $studentNameError </h3>";
exit();
}
//Code to check that the Tutor Name field is completed
if(empty($_POST['tutorName']))
{
echo "<h3>You did not select a tutor name. Please go back and select your name from the tutors list</h3>";
exit();
}
//Code to check that the Procedure field is completed
if(empty($_POST['procedure']))
{
echo "<h3>You did not select a procedure. Please go back and enter the name of the procedure which you undertook</h3>";
exit();
}
//Code to check that the Grade field is completed
if(empty($_POST['grade']))
{
echo "<h3>You did not select a grade. Please go back and select your grade from the drop down list</h3>";
exit();
}
//Code to check that the Student Reflection field is completed
if(empty($_POST['studentReflection']))
{
echo "<h3>The student did not enter any comments for this procedure. Student reflection is required for each procedure. Please go back and enter any comments</h3>";
exit();
}
//Code to check if the tick box is checked that the tutor comment is entered
if(!strlen($_POST['tutorComments']) && isset($_POST['alert']))
{
echo "<h3>You must enter a reason why you have clicked the alert box</h3>";
exit();
}
大変ありがとうございます。 – Mattrsa