我有下面的代码,我想验证表单,以确保两个电子邮件匹配提交之前匹配。PHP我可以在提交表单之前检查两个电子邮件是否匹配?
电子邮件在线24 在此先感谢。
<?php
include_once 'includes/config.php';
$pageTitle = 'Members';
include HEADER;
?>
<?php
$fname = "";
$lname = "";
$email1 = "";
$email2 = "";
?>
<p>To create an account with us please fill out the form below</p>
<form action="sendRegister.php" method="get">
First Name: <input name="new[fname]" type="text"><br>
Last Name: <input name="new[lname]" type="text"><br>
</form>
Email : <input name="new[email1]" required="" type="email" value="<?php echo $email1;?>"><br>
Re-Enter Email : <input name="new[email2]" required="" type="email" value="<?php echo $email2;?>"><br>
Password: <input name="new[password1]" type="password"><br>
Re-enter password:<input name="new[password2]" type="password"><br>
Gender: <select name="new[gender]">
<option value="Male">
Male
</option>
<option value="Female">
Female
</option>
</select><br>
State of Residence:<select name="new[states]">
<option value="NY">
New York
</option>
<option value="NJ">
New Jersey
</option>
</select><br>
<br>
<?php
if(isset($email1) != $email2){
echo 'please correct your email';
}
?>
<input type='submit' value='submit'>
</form>
<?php
include FOOTER;
?>
我总是复制,并在询问两次提交地址粘贴;所以它几乎没有什么好处 - 我总是通过向用户发送一封电子邮件到地址并让他们回复一个特定的链接密钥来验证电子邮件。 – 2013-02-23 22:10:21
你有一个额外的关闭标签到你的表单。 – cwallenpoole 2013-02-23 22:13:13