0

私はワードプレスで従業員フォームを作成しています.ページを作成してそこで作業しています.すべてが検証でも正常に機能しています.しかし、複数のテキストエリアフィールドに検証を適用すると、フォームが処理されません. 1 つのテキストエリアに対して有効です。

    if(trim($_POST['comments']) === '') {
    $commentError = 'Please enter a message.';
    $hasError = true;
    } else {
    if(function_exists('stripslashes')) {
    $comments = stripslashes(trim($_POST['comments']));
    } else {
    $comments = trim($_POST['comments']);
    }

}

そして、ここに検証を表示している私のhtmlがあります

<li class="left margin-lef-00">
<label for="commentsText"><?php _e('Message:', 'mojothemes') ?></label><br />
<textarea name="comments" id="commentsText" rows="8" cols="30" class="required requiredField">
<?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?>
</textarea>
<?php if($commentError != '') { ?>
<p><div class="error"><?php echo $commentError; ?></div></p>
<?php } ?>
</li>

ここに2番目のテキストエリアphpコードがあります

if(trim($_POST['adress']) === '') {
$adressError = 'Please enter your address.';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$adress = stripslashes(trim($_POST['adress']));
} else {
$adress = trim($_POST['adress']);
}
}

これは、php検証を使用した2番目のテキストエリアのhtmlコードです

<li class="left margin-top-15">
<label for="Address"><?php _e('Address :', 'mojothemes') ?></label><br />
<textarea name="Address" id="Address" rows="8" cols="30">
<?php if(isset($_POST['adress'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['adress']); } else { echo $_POST['adress']; } } ?>
</textarea>
<?php if($AdressError != '') { ?>
<p><div class="error"><?php echo $AdressError; ?></div></p>
<?php } ?>
</li>

しかし、別のテキストエリアの値を変更すると、フォームと競合し、送信されません。

4

0 に答える 0