Help - Search - Members - Calendar
Full Version: Figured I may as well ask this here...
Hostony Board > General Support > PHP/MySQL
johnny
Hey guys,

I'm posting this here because I really don't know of any other forums, and I'm too lazy to look for one smile.gif I have written a very basic change password script for my website. However, it doesn't seem to be very stable at all. I can change my password and it would work perfectly fine. But the next day, it seems to go haywire, and the password no longer works.

Are there any PHP guru's out there that can help?

Here's the code. If there's any other info you need, just ask.

CODE
<?

session_start();

include 'db.php';

switch($_POST['change']){
    default:
    include 'new_pw.php';
    break;
    
    case "change":
    change_pw($_POST['password']);
    break;
}
function change_pw($password){
    if(!$password){
 echo "Please enter in a valid password.<br />";
 include 'new_pw.php';
 exit();
    }

    $db_password = md5($password);
    
    $sql = mysql_query("UPDATE users SET password='$db_password' WHERE userid='$userid'");
    
    $subject = "Your Password at Tasmo.org!";
    $message = "Hi, you have recently changed your password.
    
Username: $userid
    New Password: $password
    
    Thanks!
    Tasmo.org Staff
    
    This is an automated response, please do not reply!";
    
    mail($email_address, $subject, $message, "From: Tasmo.org<admin@tasmo.org>\nX-Mailer: PHP/" . phpversion());
    echo "Your password has been changes successfully.<br />";
    include 'login_u.php';
}
?>


Thanks,
Johnny
kingtaco
well the only thing that i can think of, is that perhaps your variables are confused.

if "password" is the variable that stores the current password, and also the variable that you assign the new password too, your compiler may be getting jacked up.

Try renaming your new password variable to something like $new_pass.

That may solve your problems
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.
IPS Driver Error

IPS Driver Error

There appears to be an error with the database.
You can try to refresh the page by clicking here