# This will generate a new password if user has forgotton password

<?php
/***************************************************************************
 *			forgot1.php                   	                   *
 *                     	          				           *
 *   File Info:		  Forgot password                                  *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("config.php");
include ("./your-header.inc");
include ("./tests.php");
if ($_SERVER['REQUEST_METHOD'] == "POST") 
{
        # escape data and set variables
        $username = addslashes($_POST["username"]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Generate temporary user password</TITLE>
</HEAD>
<BODY>
<?php
$table = "users";
$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");

$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database 'mydata'...Please press 'Create Database' to create new database.");
$sql = "select * from $table where username = '$username'";
$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
$nrow = mysql_num_rows($rs);
if ($nrow == '0')
{
	echo "<br><br><center><img src=images/line.gif border=0 width=450 height=1><br><font face = verdana color = darkgreen size=2>Opps...unable to obtain password hint for username '$username'<br>Please make sure you entered this correctly. <img src=images/bullets.gif border=0><a href =forgot.php > Re input username</a></font><br><img src=images/line.gif border=0 width=450 height=1></center><br><br>";
}
else
{
	while($row = mysql_fetch_array($rs))
	{
		$hint = $row["hint"];
	}
echo "<center><img src=images/forgot.gif border=0></center>";
echo "<center><table width=450 border=1 cellspacing=0 cellpadding=0 height=150>
<tr><td width=650 bgcolor=#CCCCCC height=10><font face=verdana size=2>$header - Password Hint for Forgotten Password</font></td></tr>
<tr><td width=650 bgcolor=#FFFFFF height=140>";
echo"<center><font face = verdana size=3>Your password hint for username '$username' is</font></center><br>
<center><font face=verdana size=3 color=navy>Your password hint is '$hint'</font></tr></td></table><br></center><p align = center><font face=arial size=2 color=green>TIP: You are reminded to regularly change your password for security reasons at least once a month.</font></p>";
}
include ("./your-footer.inc");
?>
</html>
</body>
