我有下面的代碼,我想驗證表單,以確保兩個電子郵件匹配提交之前匹配。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