I'm posting this here because I really don't know of any other forums, and I'm too lazy to look for one 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';
}
?>
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