お問い合わせフォームを作成しようとしていますが、input type=text の検証を行う必要がありますが、いくつかの間違いがあるようで、見つけることができません。手伝って頂けますか?コードは次のとおりです。
<td>
Name*:<input type="text" name="name" id='name2' class="name1" />
</td>
<td>
Email*:<input type='text' name="email" class="email1" id='email2'/>
</td>
</tr>
<tr>
<td colspan="2" rowspan="2">
Message*: <br />
<textarea name='msg' style="float:right;" class="msg1" id='msg2'>
</textarea>
</td>
そしてここ:
<?PHP
$nml = strlen($_POST['name']);
$eml = strlen($_POST['email']);
$msgl = strlen($_POST['msg']);
if(isset($_GET['sent'])) {
if($nml<1) {
if($eml<1) {
if($msgl<1) {
exit("<script>document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Name*, Email* and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red';</script><center><font color='red'>Name* and Email* fields are required</font></center>");
}
exit("<script>document.getElementById('name2').style.borderColor='red'; <center><font color='red'>Name* field is required</font></center>");
}
if($eml<1) {
if($msgl<1) {
if($nml<1) {
exit("<script>document.getElementById('email2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Email*, Name * and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('email2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Email* and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('email2').style.borderColor='red';</script><center><font color='red'>Email* field is required</font></center>");
}
if($msgl<1) {
if($nml<1) {
if($eml<1) {
exit("<script>document.getElementById('msg2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red';</script><center><font color='FF0000'>Message*, Name* and Email* Fields are required</font></center>");
}
exit("<script>document.getElementById('msg2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red';</script><center><font color='FF0000'>Message* and Name* Fields are required</font></center>");
}
exit("<script>document.getElementById('msg2').style.borderColor='red';</script><center><font color='FF0000'>Message* Field is required</font></center>");
}
}
?>
修正を手伝ってください。何度も試しましたが、修正できません。私には難しすぎる