Location: PHPKode > projects > Simple SMS Site Software > simple-sms-site-software/do_change_pass.php
<?php
/******************************************************************************
************** Simple SMS Site Software *********************************
************** SSSSv1.0*****************************************************
************** by (aq) limited http://aql.com *******************************
************** All Rights Reserved ******************************************
************** Please read COPYRIGHT file prior to modification********
********************************************************************************/

session_start();

$user = $_SESSION['user'];
$pass = md5($_POST['current']);
$new1 = $_POST['new1'];
$new2 = $_POST['new2'];

include("inc/dbinfo.inc.php");
include("inc/header.inc.php");

if ($access == "forbidden") {
	include("inc/restricted.inc.php");
}
elseif ($access == "locked") {
	include("inc/restricted.inc.php");
}
else {

	$query = "SELECT password FROM users WHERE username = '$user'";
	$result = mysql_query($query);

	if (!$result) {
	   echo 'Could not run query: ' . mysql_error();
	   exit;
	}
	$row = mysql_fetch_row($result);
	
	if ($row[0] != $pass) { // 0 matches - incorrect details
		include("inc/restricted.inc.php");
		}
	else {
		if ($new1 != $new2) {	
		?>
			<p align="center">New passwords do not match</p>
		<?
		exit; 
		}
		else {
			$new1 = md5($new1);
			$query = "UPDATE `users` SET `password` = '$new1' WHERE `username` = '$user' LIMIT 1";
			$result = mysql_query($query);
			if (!$result) {
			   	echo 'Could not run query: ' . mysql_error();
	   			exit;
			}
			else {
			?>
				<p align="center">Password updated</p>
			<?
			}
		}
	}
}
include("inc/footer.inc.php");
?>
Return current item: Simple SMS Site Software