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 8770131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:30:02+00:00 2026-06-13T17:30:02+00:00

Below is a script that is run when a Change Password button is clicked

  • 0

Below is a script that is run when a Change Password button is clicked for a form. The form contains 2 password fields, one for the new password, and one for confirming the new password. Here is the action script of the form:

<?php
session_start();

include("func.php");

$NewPassword = mysql_real_escape_string(md5($_POST['newpassword']));
$Confirm = mysql_real_escape_string(md5($_POST['confirmnewpassword']));
$userid = $_SESSION['username'];

if (!isset($NewPassword) || !isset($Confirm)) {
    header("Location: ../error.php");
    die("Error");
}else if ($NewPassword <> $Confirm) {
    header("Location: ../error.php");
    die("Error");
}else{
    dbConnect();

    mysql_query("UPDATE users SET password='$Confirm' WHERE username='$userid'");

    mysql_close($connect);

    header("Location: ../profile.php");
    die("Success");
}
?>

Even when the 2 password fields on the form are empty or do not match, the password is still updated in the database. Any reason for why this could be?

I appreciate any help offered.

  • 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-06-13T17:30:09+00:00Added an answer on June 13, 2026 at 5:30 pm

    You do not need mysql_real_escape_string enclosing the md5 function, as md5 returns an hex number.

     if (!isset($NewPassword) || !isset($Confirm)) {
    

    will never evaluate to true, you should check if $_POST[‘newpassword’] and $_POST[‘confirmnewpassword’] are not empty – in this case if the passwords are both empty the password will be updated.

    About the passwork being updated even if the password are different, are you 100% sure you are passing the variables using POST and not GET and the names of the parameters are ‘newpassword’ and ‘confirmnewpassword’?

    Try putting an “echo” to display the value of the variables to make sure you are passing the parameters properly, 99% the problem is there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to modify the script below to click a button that looks
Below you could see template of SQL script that i'm trying to execute on
I was searching for a drop down list script that auto-updates the content below
I have the script shown below that displays a list of records from a
i am trying to run the below script SELECT field_value FROM jos_js_res_record_values jrv INNER
How would I change the below script to edit the original file instead of
I'm writing a powershell v2 script that I'd like to run against a remote
I 'm wondering of any mechanism that one could use to change the directory
I have tested the below script on a demo page which is not using
I've tried the below script but I am getting an error: dim cn, rs

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.