私はPHPを初めて使用しており、以下を達成しようとしています。ユーザーが送信ボタンをクリックすると、PHPファイルをチェックし、エラーが見つかった場合は実行を停止してエラーメッセージを表示するか、続行する必要があります。PHP内のフォームからエラーをキャッチ
<?php include('mobile_check.php'); ?>
<div class="tab-pane active" role="tabpanel" id="step1">
<div class="mobile-grids">
<div class="mobile-left text-center">
<img src="images/mobile.png" alt="" />
</div>
<div class="mobile-right">
<h4>Enter your mobile number</h4>
<label>+91</label><input type="text" class="mobile-text" name="req_number" value="" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '';}" required="">
</div>
<?php echo $mobileError; ?>
</div>
<ul class="list-inline pull-right">
<li><button type="button" name="mob_submit" class="mob-btn btn btn-primary next-step">Next</button></li>
</ul>
</div>
そして、私のPHPコードは次のような例外である必要があり
<?php
if(isset($_POST['mob_submit'])) {
if (empty($req_number)) {
$error = true;
$mobileError = "Please Enter Mobile No.";
} else if (!preg_match("/^[0-9 ]{10}+$/",$req_number)) {
$error = true;
$mobileError = "Please Reenter correct no.";
}
}
?>
コードをフォーマットすると、スクロールする必要はありません。ありがとうございます。 – nogad
"実行を停止し、エラーメッセージを表示するか、続行してください。だからいつそれは止まりますか?それはいつですか? – nogad