Re-confirm password script

I was looking through the forums and managed to find this useful script for password confirmation

if($_POST['password']!==$_POST['passwordconfirm']) {

echo "Your passwords did not match";

} else {

// success page here


Do i have to have create a field to store the ‘passwordconfirm’ variable in my database as well?

Here is snippet of my coding

if($PASSWORD!=$repassword) {
echo "Your passwords did not match";

I declared ‘repassword’ as a variable to be checked against ‘PASSWORD’. And if it fits, only ‘PASSWORD’ will be stored.

I’m not sure if i got it right

Please advise.

Thank you

Here’s what I would do. Have a page with a form and two password fields, password and confirmpassword, or something similar. Then, on your page that processes the form, use something like this:

if($_POST['password'] != $_POST['confirmpassword']){
   echo "Your passwords did not match.";

If it passes and both password fields are the same, then I’d just store one password in your database.