Location: PHPKode > projects > Insecticida > insecticida_wiki/admin/password.php
<?
###################################################
#Copyright (C) 2001 Stuart Wigley (hide@address.com) 
#
#password.php 18/04/2001   
#
#This file is part of workbench.
#
#workbench is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#workbench is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with workbench; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#####################################################
session_start();
require_once("../config.php");
#if user has logged in get $login from session
if ($HTTP_SESSION_VARS["login"] && session_is_registered("login")){
	$login = $HTTP_SESSION_VARS["login"];
	require_once("$path/connect.php");
	require_once("$path/general.php"); 
	$query = mysql_query("select * from users where users.login='$login'") or die(mysql_error());
	$result = mysql_fetch_array($query);
	if ($HTTP_POST_VARS["password1"] && $HTTP_POST_VARS["password2"] && $HTTP_POST_VARS["password3"]){
		if (strcmp($HTTP_POST_VARS["password2"], $HTTP_POST_VARS["password3"])){
			$theError = "<li>You didn't enter the same new password in both fields.</li>";
			}
		if (strcmp(md5($HTTP_POST_VARS["password1"]), $result[password])){
			$theError .= "<li>You didn't enter your old password correctly.</li>";
			}
		if (!$theError){
			$thePassword = md5($HTTP_POST_VARS["password2"]);
			mysql_query("update users set password='$thePassword' where login='$login'") or die (mysql_error());
			# session_destroy();
			#header("Location: $url/main.php");
			#exit;
		}
	}
	include("$path/header.php");
?>
   <form method="post" action="password.php" name="password" onSubmit="return validateForm('password')">
	<table cellspacing="0" class="table3">
	 <tr class="rowtitle">
	  <td colspan="2"><h5>Change Password</h5></td>
	 </tr>
	 <tr>
	  <td colspan="2"><p>Use this page to change your password. Don't worry if you ever forget your password - you can always ask
	  your Administrator to reset it for you. </p></td>
	 </tr>
	 <tr>
	  <td colspan="2"><hr></td>
	 </tr>
	 <tr>
	  <td width="200">Old Password</td>
	  <td width="400"><input type="password" name="password1" size="20" maxlength="50"></td>
	 </tr>
	 <tr>
	  <td width="200">New Password</td>
	  <td width="400"><input type="password" name="password2" size="20" maxlength="50"></td>
	 </tr>
	 <tr>
	  <td width="200">Confirm Password</td>
	  <td width="400"><input type="password" name="password3" size="20" maxlength="50"></td>
	 </tr>
	 <tr>
	  <td width="200">&nbsp;</td>
	  <td width="400"><input type="Submit" value="Submit" onfocus="this.blur()"><input type="Reset" value="Reset" onfocus="this.blur()"></td>
	  </tr>
	  <?
	  if ($theError){
	  	echo("<tr><td colspan=\"2\"><h5>$theError<h5></td></tr>");
	   	}
	   ?>
	 </table>
	</form>
<?
include("$path/footer.php");
}
else{
	include("$path/login.php");
	#exit;
	}
?>
Return current item: Insecticida