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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:48:17+00:00 2026-06-18T02:48:17+00:00

ok so i am running a reset password script, its supposed to replace the

  • 0

ok so i am running a reset password script, its supposed to replace the password with the sha1 hashed version of password01 if successful it should return the success message if not then the failed message, but its returning the failure message weather it works or not which it always does! any ideas? i have inserted the code below:

<?php 
session_start();
$host= $_SESSION["dbhost"]; 
$username= $_SESSION["dbuser"]; 
$password= $_SESSION["dbpass"]; 
$db_name= $_SESSION["dbname"];
$tbl_name="users"; // Table name 

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

$userid = $_POST['id'];
$password = 'password01';    
$hashpass = sha1($password);

//$result = mysql_query("SELECT password FROM $tbl_name WHERE id='$userid'");
$sql=mysql_query("UPDATE $tbl_name SET password='$hashpass' where id='$userid'"); 

if (mysql_query($sql)) {
echo "<ul id='breadcrumbs-one'>";
echo "<li><a href=''>Users</a></li>";
echo "<li><a href='' class='current'>Reset</a></li>";
echo "</ul>";
echo "<div class='tn-box tn-box-color-3 mcenterlow'>";
echo "<p>The Opperation was Sucessful!<br><a href='?users'>Add Another?</a></p>";
echo "<div class='tn-progress'></div>";
echo "</div>";
}
else {
echo "<ul id='breadcrumbs-one'>";
echo "<li><a href=''>Users</a></li>";
echo "<li><a href='' class='current'>Reset</a></li>";
echo "</ul>";
echo "<div class='tn-box tn-box-color-1 mcenterlow'>";
echo "<p>The Opperation was Not Sucessful!<br><a href='?users'>Try Again?</a></p>";
echo "<div class='tn-progress'></div>";
echo "</div>";
}
?> 
  • 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-18T02:48:18+00:00Added an answer on June 18, 2026 at 2:48 am

    Apart from the comments below your question, the reason your if is failing, is that you are using mysql_query on the result of another call to mysql_query.

    To solve that, you should change your condition to:

    if ($sql) {
    

    (for an UPDATE query, mysql_query return true on success and false on failure)

    And you should really switch to PDO (or mysqli) with prepared statements and bound variables to get rid of the sql injection problem you have.

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

Sidebar

Related Questions

Running my script through Devel::NYTProf showed that the following portion of code took up
Running the following line in my script gives me a Permission denied error: $config_out
All of the passwords in WordPress databases are hashed. I'm running 20+ blogs with
How on earth do you reset the sa password? I know how to go
How do users reset passwords while in off-line mode. We are running the site
I am running a batch script and somewhere the user has to access a
I am trying to implement a password reset functionality on my company website where
I have a cap script that performs some lengthy compilation steps before running any
after running rake db:reset i rund rake db:populate and i'm getting this error don't
To reset the admin password of SolusVM I am executing the following command :

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.