Location: PHPKode > projects > DDL CMS > Upload these files to your webspace/admin/adminpass.inc
<h2>Change Admin Username and Password</h2>
<p>
<?php
	if(isset($_POST) && count($_POST) > 0)
	{
		if(isset($_POST) && count($_POST) > 0 && checkPostForm('adminPass', $_POST) === TRUE)
		{
			if($_POST['newUser'] != $_POST['newUser2'] || $_POST['newPass'] != $_POST['newPass2'])
			{
				echo 'New passwords do not match. <a href="javascript:history.go(-1)">Go back</a> and try again.</p>' . "\n";
			}
			else
			{
				$userHash = hash('sha512', $_POST['oldUser']);
				$passwdHash = hash('sha512', $_POST['oldPass']);
				$passwordQuery = dbcom("SELECT * FROM auth WHERE user = '$userHash' AND pass = '$passwdHash' LIMIT 1;");
				if(mysql_num_rows($passwordQuery) == 0)
				{
					echo 'Old username and/or password is incorrect. <a href="javascript:history.go(-1)">Go back</a> and try again.</p>' . "\n";
				}
				else
				{
					$newUserHash = hash('sha512', $_POST['newUser']);
					$newPasswdHash = hash('sha512', $_POST['newPass']);
					dbcom("UPDATE auth SET user = '$newUserHash', pass = '$newPasswdHash' WHERE user = '$userHash' AND pass = '$passwdHash' LIMIT 1;");
					echo 'Administrator username and password changed successfully.';
					$headers = "FROM: ".$admin_email."\n";
					$headers .= "X-Sender: ".$admin_email."\n";
					$headers .= "Return-Path: ".$admin_email."\n";
					$message = $site_name . ' Admin username has been changed to ' . $_POST['newUser'] . ' and admin password has been changed to ' . $_POST['newPass'] . ' from IP ' . $_SERVER['REMOTE_ADDR'] . '.  If you did not perform this change, please login and change your password right away.';
					@mail($admin_email, $site_name . ' Admin Username/Password Changed', $message, $headers);
				}
			}
		}
		else
		{
			 echo '<p>Changing administrative username/password failed. Please, check the lengths and contents of form fields. <a href="javascript:history.go(-1)">Go back</a> and try again.</p>' . "\n";
		}
	}
	else
	{
?>
	<form action="ddl.php?go=adminpass" method="post">
		<table>
			<tr>
				<td colspan="2"><b>Change Your Username:</b></td>
			</tr>
			<tr>
				<td align="right"><label for="txtOldUser">Old:</label></td>
				<td><input type="text" name="oldUser" id="txtOldUser" maxlength="128" size="30" /></td>
			</tr>
			<tr>
				<td align="right"><label for="txtNewUser">New:</label></td>
				<td><input type="text" name="newUser" id="txtNewUser" maxlength="128" size="30" /> Min. 6 characters</td>
			</tr>
			<tr>
				<td align="right"><label for="txtNewUser2">Confim:</label></td>
				<td><input type="text" name="newUser2" id="txtNewUser2" maxlength="128" size="30" /> Min. 6 characters</td>
			</tr>
			<tr>
				<td colspan="2" height="20"></td>
			</tr>
			<tr>
				<td colspan="2"><b>Change Your Password:</b></td>
			</tr>
			<tr>
				<td align="right"><label for="txtOldPass">Old:</label></td>
				<td><input type="password" name="oldPass" id="txtOldPass" maxlength="128" size="30" /></td>
			</tr>
			<tr>
				<td align="right"><label for="txtNewPass">New:</label></td>
				<td><input type="password" name="newPass" id="txtNewPass" maxlength="128" size="30" /> Min. 8 characters</td>
			</tr>
			<tr>
				<td align="right"><label for="txtNewPass2">Confim:</label></td>
				<td><input type="password" name="newPass2" id="txtNewPass2" maxlength="128" size="30" /> Min. 8 characters</td>
			</tr>
		</table>
		<br><br>Username must be at least six (6) characters long. 
		<br>Password must be at least eight (8) characters long. 
		<br>It is strongly recommended that you choose a password with both letters and numbers.
		<br><br><input type="submit" value="Change Username &amp; Password" />
	</form>
<?php
	}
?>
</p>
Return current item: DDL CMS