i made the option for username password retype password on my form how can i make it so wen the information is processed it will make sure both passwords match and give u a popup warning if they dont?
Printable View
i made the option for username password retype password on my form how can i make it so wen the information is processed it will make sure both passwords match and give u a popup warning if they dont?
When the forum is submitted, read the 'newpassword' and 'confirmnewpassword' fields, compare them, and depending upon that, you can show a message or continue with submission of the form.
All you need is a simple string comparision:
You can also use client side Javascript to check this before the form is submitted to your script.PHP Code:if ($_POST['password'] != $_POST['confirm_password']) {
/* passwords don't match - redirect back to the form */
}
You should also still check in the PHP script even if you yuse javascript to check as this can be bypassed.Code:<script type="text/javascript">
<!--
function check_pw(theForm)
{
if(theForm.password.value != theForm.confirm_password.value)
{
alert('Your passwords do not match.');
theForm.password.value = '';
theForm.confirm_password.value = '';
theForm.password.setFocus();
return false;
}
return true;
}
//-->
</script>
..
..
<form onsubmit="return check_pw(this);">