Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7071135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:04+00:00 2026-05-28T05:39:04+00:00

Found the answer!! Found the answer after a long break from looking at it!

  • 0

Found the answer!!

Found the answer after a long break from looking at it!

was just simply changing

$querynewpass = "UPDATE tz_members SET `pass`='".$_POST['$passwordnew1']."' WHERE usr='{$_SESSION['usr']}'";

to:

$querynewpass = "UPDATE tz_members SET `pass`='".md5($_POST['passwordnew1'])."' WHERE usr='{$_SESSION['usr']}'";

just the simple md5 that i had missed off!

The Problem:

im trying to change a user password using a form where they enter their current password and a new password. it should check the mySQL database to see if their current password that was entered matches the current session user they are logged into and then update the mySQL database to the new password. Here is the script i have for it so far:

if($_POST['submit']=='Change')
{
    // Checking whether the Password Change form has been submitted
    
    $err = array();
    // Will hold our errors
    
    
    if(!$_POST['password1'] || !$_POST['passwordnew1'])
        $err[] = 'All the fields must be filled in!';
    
    if(!count($err))
    {
        $_POST['password1'] = mysql_real_escape_string($_POST['password1']);
        $_POST['passwordnew1'] = mysql_real_escape_string($_POST['passwordnew1']);
        
        // Escaping all input data

        $row = mysql_fetch_assoc(mysql_query("SELECT id,usr FROM tz_members WHERE usr='{$_SESSION['usr']}' AND pass='".md5($_POST['password1'])."'"));

        if($row['usr'])
        {
            // If everything is OK change password
            
            $querynewpass = "UPDATE user SET `password`='".$_POST['$passwordnew1']."' WHERE id='".$_SESSION['usr']."'";
                        $resultnewpass = mysql_query($querynewpass) or die(mysql_error()); 
            
        }
        else $err[]='Wrong Password To Start With!';
    }
    
    if($err)
    $_SESSION['msg']['passwordchange-err'] = implode('<br />',$err);
    // Save the error messages in the session

    header("Location: index.php");
    exit;
}

but it comes with an error "Table ‘databasename.user’ doesn’t exist"
i have a login and register form that work using this method without error!

UPDATE:
i have a database that has a table called tz_members and the columns are id, pass, user, regIP and dt

my mysql query is now:

$querynewpass = "UPDATE tz_members SET `pass`='".$_POST['$passwordnew1']."' WHERE usr='{$_SESSION['usr']}'";

UPDATED AGAIN
adding the form code for you to see:

    <!-- Pass Change Form -->
            <form action="" method="post">      
            <?php
                    
                    if($_SESSION['msg']['passwordchange-err'])
                    {
                        echo '<div class="err">'.$_SESSION['msg']['passwordchange-err'].'</div>';
                        unset($_SESSION['msg']['passwordchange-err']);
                    }
                    
                    if($_SESSION['msg']['passwordchange-success'])
                    {
                        echo '<div class="success">'.$_SESSION['msg']['passwordchange-success'].'</div>';
                        unset($_SESSION['msg']['passwordchange-success']);
                    }
                ?>
                    
                <label class="grey" for="password1">Current Password:</label>
                <input class="field" type="password" name="password1" id="password1" value="" size="23" />
                <label class="grey" for="password">New Password:</label>
                <input class="field" type="password" name="passwordnew1" id="passwordnew1" size="23" />
                <input type="submit" name="submit" value="Change" class="bt_register" />
            </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:39:05+00:00Added an answer on May 28, 2026 at 5:39 am

    Your are using two different tables (and columns) in the two queries that seem to be related to the same table.

    Check your schema and adjust the second query appropriately.

    The second query should probably be something along the lines of:

    $querynewpass = "UPDATE tz_members SET `pass`='".md5($_POST['passwordnew1'])."' WHERE usr='{$_SESSION['usr']}'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I just found my problem after writing this long post explaining every little
a question I haven't found an answer to after googling for a long time
I haven't found my answer after reading through all of these posts, so I'm
Sorry answer found while typing I am trying to connect to an external webservice
I found this answer and it sounds like almost exactly what I'm doing. I
I haven't found an answer to this particular question; perhaps there isn't one. But
I've found a answer how to remove diacritic characters on stackoverflow, but could you
I haven't exactly found the answer to this, maybe there is no best one.
All the googling around hasn't found an answer for me yet... I have one
This took me a while to figure out and I found the answer on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.