Password changer!

Socius Decennalis
Decennium
Joined
Apr 8, 2009
Messages
60
Reaction score
8
Hi all,

I noticed that some of you wanted a script that can change passwords of existing accounts. Well, here it is:
PHP:
<?php
//This script was created by Diumelia for ragezone forums.
ini_set('display_errors', 0); 
$connection = mssql_connect('YOURHOST', 'sa', 'YOURPASSWORD'); // <<== Change YOURHOST and YOURPASSWORD

if(!connection || !mssql_select_db('ACCOUNT_DBF', $connection)) 
{
    die('Unable to connect or select database!');
}

$checkusername = $_POST['Username'];
$query = mssql_query("SELECT account FROM ACCOUNT_TBL WHERE account = '$checkusername'");
$result = mssql_fetch_row($query);

$checkpassword = $_POST['FirstPassword'];
$query2 = mssql_query("SELECT password FROM ACCOUNT_TBL WHERE account = '$checkusername'");
$resultpass = mssql_fetch_row($query2);

$passwordcheck = md5('nForceIsGay' . $_POST['FirstPassword']);

if(isset($_POST['submit'])){
    if($_POST['Username'] == ""){
        $error = '<font color="red">Please enter a username.</font>';
    }
	else if($result[0] != $checkusername){
        $error = '<font color="red">This username doesn\'t exist. </font>';
    }
	else if($_POST['FirstPassword'] == ""){
		$error = '<font color="red">Please enter your password.</font>';
	}
	else if($passwordcheck != $resultpass[0]){
		$error = '<font color="red">Please enter the correct password.</font>';
	}
	else if($_POST['NewPassword'] == ""){
		$error = '<font color="red">Please enter a new password.</font>';
	}
	else if($_POST['NewPassword2'] == ""){
		$error = '<font color="red">Please repeat your new password.</font>';
	}
	else if($_POST['NewPassword'] != $_POST['NewPassword2']){
		$error = '<font color="red">New passwords do not match.</font>';
	}
	else{
		$NewPassword = md5('nForceIsGay' . $_POST['NewPassword']);
		mssql_query("UPDATE ACCOUNT_TBL SET password = '$NewPassword' WHERE account = '$checkusername'");
		$error = '<font color="green">Your password has been succesfully changed!</font>';
	}
}

echo '<form action="changepass.php" method="post"><br />';
echo 'Username: <input type="text" name="Username" /><br />';
echo 'Password: <input type="password" name="FirstPassword" /><br />';
echo 'New password: <input type="password" name="NewPassword" /><br />';
echo 'Repeat new password: <input type="password" name="NewPassword2" /><br />';
echo '<input type="submit" name="submit" value="Change" /><br /><br />';
echo '</form>';
echo $error
?>

How to use:
#1: Change YOURHOST and YOURPASSWORD at the top of this script to your host and your database password
#2: Save this script as changepass.php
#3: Enjoy! :D

Credits:
Credits go to me! :thumbup:

If you use this script for public servers, please be aware that It can be easily abused.
 
I got this problem -,-

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\changepass.php on line 26

Can u help me!
 
Please help me :(

Learn on your own. It's the best way to learn. Research that error and find all the information you can on it and you'll eventually be able to fix it yourself. It might take longer than getting help from other people, but like Glaphan has said before, it'll make you smarter so you know how to fix that mistake next time around. Be a learner, not a leecher.
 
nForseIsGay? ;o

WTF? o.O xD
Most ppl wont know how to use the script ... :o if you could explain it :D not just, 'copy paste this ar changepass.php!' or soemthing like that xD There is a bunch of ppl looking for help like if the world was ending.
 
Last edited:
Of course it can be easily abused... You see, IF you haven't got the Email check, that makes things way too easy.. IF the script would check for username AND email address, then the function would proceed and change the password for you, That would be more secure than it is right now..

Anyways, was an idea thats all, since most of the register forms do have email fields.. :)
 
Back