| 0 comments ]

I hacked this script out of a few pieces of code I found across the net. It basically checks that the current username and password match as well as whether or not the $newpassword and $confirnpassword match if so it inserts it in the DB as an md5 hash.

All you should need to do to get it to work on your site is add your DB connection info and change the table name and column names in the query, that should be it.

You can download the source here:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This script will check that the current username and password match and if it does
// it checks that the $newpassword and the $confirmpassword match before inserting the
// $newpassword in the DB.
// Form input variables
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$newpassword = mysql_real_escape_string($_POST['newpassword']);
$confirmpassword = mysql_real_escape_string($_POST['confirmpassword']);
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
} else {
$result = mysql_query("SELECT pass FROM members WHERE usr='$username' and pass = '".md5($password)."'")or die("Query failed: " . mysql_error());
if(mysql_num_rows($result)){
if($newpassword==$confirmpassword){
$sql=mysql_query("UPDATE members SET pass='".md5($newpassword)."' where usr='$username'");
if($sql)
{
echo "Password Changed";
}
else
{
// In case when problem while updating your new password
echo "Error changing password, please email webmaster@signalwarrant.com";
}
} else {
// In case when new-password and retype-password do not match
echo "New and confirmed password do not match please try again.";
}
} else {
// In case of you have not correct User name and password
echo "Current username and password do no match.";
}
}
?>

text goes here.

if($_SESSION['id']){
echo '
';
echo '

Username:


';
echo '

Password:


';
echo '

New Password:


';
echo '

Confirm Password:


';
echo '';
echo '';
} else {
echo '

Please, login and come back later!

';
}
?>
Footer goes here.

0 comments

Post a Comment