Hello everyone, first of all i like to say that the new daniweb webdesign is AMAZING i really like it and hope this site it will become number one for programming and if it does please never BAN its users like stackowerflow do but thats other theme.. :D
I have a problem with the change password box this code should work but it doesn't any solutions ?

<!-- CHANGE PASSWORD BOX -->
    <form method="POST" action="navigation.php">
        <div class="modal fade" id="changePassword">
            <div class="modal-dialog modal-md">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Change Account Password</h4>
                    </div>
                    <div class="modal-body">
                        <p><input type="text" class="form-control" name="oldPass" placeholder="Enter Old Password"/></p>
                        <p><input type="text" class="form-control" name="newPass" placeholder="Enter New Password"/></p>
                    </div>
                    <div class="modal-footer">
                        <input type="submit" class="btn btn-success btn-block" data-dismiss="modal" name="changePass">Change Password</input>
                    </div>
                </div>
            </div>
        </div>
        <?php
        if(isset($_POST['changePass'])) {
            $newPass = $_POST['newPass'];
            $oldPass = $_POST['oldPass'];

            $password = getUserData('users', 'Password');

            if($oldPass != $password) {
        ?>
            <p>Incorrect 'Old Password'</p>
        <?php
            } else if($newPass == $password) {
        ?>
            <p>You must use different password!</p>
        <?php
            } else {
                $user = getUserData('users', 'UserUsername');
                $email = getUserData('users', 'Email');
                $sql = "UPDATE `users` SET `Password`='".$newPass."' WHERE `Email`='".$email."' AND `UserUsername`='".$user."'";
                $return = $conn->query($sql);
        ?>
            <p>Password changed successfully.</p>
        <?php
            }
        }
        ?>
    </form>
Member Avatar for diafol

Where are you hashing this password? I can't see a hashing function. Really hope you're not storing passwords as plaintext?

What exactly doesn't work? If you echo the generated query, does it execute in phpMyAdmin? Is $conn a valid object?

Nothing happens when i press the button, just closing the modal box
Yea it works when i echo into the SQL and yeah conn is a valid object and works in other classes

Nothing at all, not even if your passwords don't match?

<form method="POST" action="navigation.php">

The form is posted to navigation.php. This is the correct script?

Yup nothing at all even if the password doesnt match and yes thats the correct script

Do you have this online somewhere to see? It is either not posting, or posting to the wrong script.

Yes i have online test site: Click Here login with these details:
Email: asd@gmail.com
Pass: asd
CLICK NEWS go down to "MORE" and find "Change Password" i dont know why the menu does not work on home page but its the same code...

It appears that the action is not set on your page. It's just <form method="POST" action>. When setting the page to <form method="POST" action="navigation.php">, the browser loads only navigation.php as expected, which appears to be your navigation sidebar. It also throws a Call to undefined function getuserdata() error, which I would guess is because you normally include that function in another section of your page. I suggest using an ajax call (documentation here if you need it) to submit your form data to a php page dedicated to handling your database entries. Have the php page return a json response to the ajax call so that you can alert the user to success/failure of the script.

Problem is solved i removed the data-dismiss="modal" idk why that happened.

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.