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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:10:52+00:00 2026-05-26T20:10:52+00:00

<? // Inialize session session_start(); // Check, if username session is NOT set then

  • 0
<? 
// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page

if (!isset($_SESSION['username'])) 
{
header('Location: AdminLogin.php');
}
?>

<html lang="en-GB" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="AdminLogin.css" type="text/css" />
<title>Welcome to ASM Services Inc.</title>

<script type="text/javascript" language=JavaScript>
var message="";
function clickIE() 
{
    if (document.all) 
    {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
</script>
</head>
<body>

<div class="login">
<?php
require("adminconfig.inc");
$user = $_SESSION['username'];
echo "<form name=form1 method=post>
<table width=100 border=0 align=center>
<tr>
<font size=5 face=Arial color=yellow>Change Password</font>
</tr>
<table>
    <tr>
        <td><font size=4 face=Tahoma color=yellow>Username:</font></td>
        <td><input type=text name='username1' value='$user' size=20 AUTOCOMPLETE = off ></td>
    </tr>
    <tr>
        <td><font size=4 face=Tahoma color=yellow>Password:</font></td>
        <td><input type=password name=password size=20 AUTOCOMPLETE = off></td>
    </tr>
    <tr>
        <td><font size=4 face=Tahoma color=yellow>New Password</font></td>
        <td><input type=password name=new_pass size=20 AUTOCOMPLETE = off></td>
    </tr>
    <tr>
        <td><font size=4 face=Tahoma color=yellow>Confirm Password:</font>:</td>
        <td><input type=password name=con_pass size=20 AUTOCOMPLETE = off></td>
    </tr>
</table>
<table>
    <tr>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type=submit value=Ok name='btnCheck'>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type=submit value=Cancel name=btnCancel onClick='this.form.reset()'>
    </tr>
</table>
</table>
</form>";
?>

<?php
require("adminconfig.inc");
$user = $_POST['username1'];
$pass = $_POST['password'];
$new_pass = trim($_POST['new_pass']);
$con_pass = trim($_POST['con_pass']);
if(isset($_POST['btnCheck']))
{
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT Log_User, Log_Pass, User_Type FROM LOG_IN WHERE  
(Log_User = '" . mysql_real_escape_string($_POST['username1']) . "') 
and 
(Log_Pass = '" . mysql_real_escape_string($_POST['password']) . "') 
and 
(User_Type = 'member')") 
or die('Query failed: ' . mysql_error() . "<br />\n$sql"); ;


//Check username and password match
if (mysql_num_rows($login) == 1) 
{
    if(trim('$new_pass') == trim('$con_pass'))
    {
        $sql=mysql_query("UPDATE log_in SET Log_Pass='$new_pass' where username='$user'"); 
        if(!$sql) 
        { 
            echo "fail updating!";
        }
        else
        {
            echo "success!";
            echo "<script type = text/javascript>";
            echo "alert('The new password has been changed successfully.');";
            echo "</script>";
        } 
    }
    else
    {
        echo "fail!";
        echo "<script type = text/javascript>";
        echo "alert('Error. New Password and Confirm Password are not the same. Please make it sure that they are the same.');";
        echo "</script>";
    }
}
}
?>

</div>

<div class="copyright">
&copy; Copyright 2011 <strong>ASM Services Inc.</strong>
</div>
</body>
</html>

This is my whole code for changing the password of the user. I really don’t what’s the exact error of my code. Whenever I change the password, it always brings to the “Error. New Password and Confirm Password are not the same”.

  • 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-26T20:10:53+00:00Added an answer on May 26, 2026 at 8:10 pm

    Your current code has:

    if(trim('$new_pass') == trim('$con_pass')) {
      // passwords match
    } else {
      // passwords don't match
    }
    

    You are comparing the strings '$new_pass' & '$con_pass' and not the variables $new_pass & $con_pass. Also don’t use should not use trim as the user might have space in his passwords.

    Change

    if(trim('$new_pass') == trim('$con_pass'))
    

    to

    if($new_pass == $con_pass)
    

    Also you read the passwords from the form as:

    $new_pass = trim($_POST['new_pass']);
    $con_pass = trim($_POST['con_pass']);
    

    You should not be using trim here as well. If the user wants to have space at the end/beginning of his password, your logic will fail as the user thinks his password has the space but the password you enter in the DB will not have space.

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

Sidebar

Related Questions

I'm trying to make a login and logout script for a page but for
why is my error message not showing if password or username is incorrect? i
I must browse a certain site that keeps a session id with indy's idhttp
I have a Spring/JPA/Groovy/Hibernate stack, (note: not grails ), and I'm finding that I'm
I have an object like this class SomeObject def initialize &block # do something
Reading code from other posts, I'm seeing something like this. struct Foo { Foo()
This is a question about asp.net WebForms and sessionstate. I know this is probably
I'm trying to model a card game in order to learn Rails. This is
This question arise while trying to write test cases. Foo is a class within
Duplicate: New to C#, why does Property Set throw StackOverflow exception? I have a

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.