Such a task: checking the entered data on the server side, interrupt the sending script and display the corresponding error message (such as "the entered name is too short", "the phone number is entered incorrectly", etc.).
What I do not understand is how to return any value when the script is completed, so that it can be intercepted in a php file with an input form. I imagine it somehow like this:
<!-- action.php - файл проверки данных и отправки сообщения --> <form id="FeedbackFrom" name="FeedbackFrom" method="post" action="request.php"> <input type="text" id="name" name="name"> <?php if ($_GET['mail'] == 0 && $errorCode == "TooShortName") { echo "<p class=\"error\"> Введённое имя слишком короткое </p>"; } else if ($_GET['mail'] == 0 && $errorCode == "TooShortName") { echo "<p class=\"error\"> Введённое имя слишком длинное </p>"; } ?> <input type="email" id="email" name="email"> <?php if ($_GET['mail'] == 0 && $errorCode == "InvalidMail") { echo "<p class=\"error\"> Адрес электронной почты ведён неправильно </p>"; } ?> <input type ="submit" id="Submitt"/> </form> - There is an
exit, but it returns nothing. The error code is caught there in some pervert way; it is not clear how to catch it in theifblock. - There are exceptions and a
try-catchconstruct. But first, you need to create a separate class for each error, and secondly, how to catch it whenrequest.phpcrashes?