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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:54:48+00:00 2026-06-14T05:54:48+00:00

I am having trouble getting this to work correctly I am trying to clean

  • 0

I am having trouble getting this to work correctly I am trying to clean up my php files and make a function that changes the users password. It works fine if I keep the copied code from the function file under function setPass in the Login_success.php file. When I copy the working code into the functions.php file with a function name setPass it does not work I am not getting an error message either. I realize that not using PDO prepared statements is unsafe but I will change it once I get this working. Here is my code for the login_success file and the functions file:

Functions.php

<?php
require 'DB.php';

function setPass(){   

foreach($conn->query("SELECT password FROM CLL_users WHERE user_name= '$userCurrent'") as $password1) {

    $old_pass = ($password1['password']);
}
$new_pass = md5($_POST['new_pass']);

    if (md5($_POST['old_password']) == ($old_pass) && ($_POST['new_pass']) == ($_POST['verify_pass'])) {

        $sql="UPDATE CLL_users SET password= '$new_pass' WHERE user_name= '$userCurrent'";

        $result=mysql_query($sql);



        echo "Match";
    } else {
        echo "Not a Match";
    }

}
?>

login_success.php

<?php
require 'functions.php';
require 'DB.php';
session_start();
session_is_registered(myusername);
$userCurrent = $_SESSION['myusername'];
$host="localhost"; // Host name 
$username="user"; // Mysql username 
$password="XXXXXX"; // Mysql password 
$db_name="db"; // Database name 
$tbl_name="CLL_users"; // Table name 
date_default_timezone_set('America/Chicago');
$dateCreated = date('m/d/Y h:i:s a', time());

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="UPDATE CLL_users SET last_login= '$dateCreated' WHERE user_name= '$userCurrent'";
$result=mysql_query($sql);

if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>

    <!DOCTYPE html>
    <html>
        <head>
            <title>user</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <LINK href="CLL.css" rel="stylesheet" type="text/css">
        </head>
        <body>    


        <form id ="css" action="" method="post">
        <div class="row">

            <label class ="formLabel" for="old_password">Old password:</label>
                <input type="password" name="old_password" id="old_password" />
       <br> <label class ="formLabel" for="new_pass">New Password:</label>
                <input type="password" name="new_pass" id="new_pass" />
       <br> <label class ="formLabel" for="verify_pass">Verify new password:</label>
                <input type="password" name="verify_pass" id="verify_pass" />


                    </div>     
            <input type="submit" />
    </form>

<?php 
    $_POST['old_password'] = $old_pass;
    $_POST['new_pass'] = $new_pass;
    $_POST['verify_pass'] = $verify_pass;
    if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    setPass($userCurrent, $old_pass, $new_pass, $verify_pass);
    }
 ?>

        </body>
    </html>
  • 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-14T05:54:49+00:00Added an answer on June 14, 2026 at 5:54 am

    I think the problem lays in the sequence of the code. You should try passing $userCurrent as a parameter, try and use this function: (I also fixed a few syntax errors)

    function setPass($userCurrent)
    {   
        foreach($conn->query("SELECT password FROM CLL_users WHERE user_name= '" . $userCurrent . "'") as $password1) {
            echo $password1['password'];
            $old_pass = ($password1['password']);
        }
        $new_pass = md5($_POST['new_pass']);
        echo "<br>";
        if (md5($_POST['old_password']) == ($old_pass) && ($_POST['new_pass']) == ($_POST['verify_pass'])) {
            $sql="UPDATE CLL_users SET password= '" . $new_pass . "' WHERE user_name= '" . $userCurrent . "'";
            $result=mysql_query($sql);
            echo "Match";
        } else {
            echo "Not a Match";
        }
        echo "<br>";
        echo md5($_POST['old_password']);
        echo "<br>";
        echo ($old_pass);
        echo "<br>";
        echo ($new_pass);
    }
    

    btw,
    what the BBQ where you thinking here, lol:

      $_POST['old_password'] = $old_pass;
      $_POST['new_pass'] = $new_pass;
      $_POST['verify_pass'] = $verify_pass;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m having trouble getting a AJAX/JSON function to work correctly. I had this function
I’m having trouble getting a AJAX/JSON function to work correctly. I had this function
I am learning python and am having trouble getting this program to work correctly.
Having some trouble getting this query to work correctly. mysql_query(DELETE FROM `table` WHERE `id`
I'm having some trouble getting this layout to work correctly in IE. The problem
I'm having trouble getting this to work. I'm writing a Vim snippet that will
I am having trouble getting this to work correctly (obviously) - I am ALMOST
Ok this seems so silly but I'm having some trouble getting this to work.
I am having trouble getting this invisibilityOfElementLocated() method to work. Here is the code
I'm having trouble getting a sample program to link correctly (in this case against

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.