im working on a password verification(php) form when the user
wants to change his/her password.
new password will be typed twice for confirmation.

if the passwords didn't match, a message box will appear (javascript).

it already worked but my problem is when that message box appears,
all the other fields in the form other than the password field becomes blank.
those fields came from a query which is done upon loging in based on
a field from the previous form.

i think after that message box appear, the result of the query becomes 0.

any help will be appreciated.
thanks in advance!

Post the code.

$user = $_POST['username'];     //from previous form after logging in

// this is the query 
$resultwelcome = mysql_query("SELECT * FROM list_table WHERE empnum = '$empid'") or die(mysql_error());
            while($row = mysql_fetch_array($resultwelcome))
            {
                $fname = $row['fcEmpFName'];
                $lname = $row['fcEmpLName'];
                $mname = $row['fcEmpMName'];
            }

//display the name in the change_pass form
Welcome <?php echo 
                                "$lname". ",". " $fname" ;?>,

<form action="change_pass.php"  method="POST">
<input type = "text" name = "usern" size = "20"> <br>
<input type = "password" name = "newpass" size = "20"> <br>
<input type = "password" name = "newpass1" size = "20"> <br>
<input type = "submit" name = "submit" value = "Save Changes">

</form>

<?php
$user=$_POST['usern'];
$newpass=$_POST['newpass'];
$newpass2=$_POST['newpass1'];
$submit=$_POST['submit'];

if ($submit=='Save Changes') {
    if ($newpass == '' || $newpass2 == '')
    {
        echo "<script>alert('Please complete the information!')</script>";    }
    else
    {
        if ($newpass == $newpass2) {
            mysql_query("UPDATE list_table SET userPassWord ='$newpass' WHERE userName='$user'") or die(mysql_error());
            echo "<script>alert('New Password already saved!')</script>";

        }else{
        //when password didnt match, there will be nothing to be displayed in the "welcome,... " part.
            echo "<script>alert('Passwords did not match!')</script>";

        }
    }
}
?>

Well, you could just use PHP to display the message.

if($newpass == $newpass2) {
//do the query
}
else {
echo "Passwords do not match!";
}

Well, you could just use PHP to display the message.

if($newpass == $newpass2) {
//do the query
}
else {
echo "Passwords do not match!";
}

thanks for the suggestion..

but i already tried that one..
there was nothing displayed also in the "welcome part.." :-(

just created a boolean type table field in the database and get that record when it is true,
all the details will be displayed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.