All you need is a simple string comparision:
PHP Code:
if ($_POST['password'] != $_POST['confirm_password']) {
/* passwords don't match - redirect back to the form */
}
You can also use client side Javascript to check this before the form is submitted to your script.
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);">
You should also still check in the PHP script even if you yuse javascript to check as this can be bypassed.