<?php require_once('../Connections/telmanik_press.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_forgot_password = "SELECT * FROM members";
$forgot_password = mysql_query($query_forgot_password, $telmanik_press) or die(mysql_error());
$row_forgot_password = mysql_fetch_assoc($forgot_password);
$totalRows_forgot_password = mysql_num_rows($forgot_password);
?>
<?php
require_once('language/class.translation.php');

if(isset($_GET['lang']))
	$translate = new Translator($_GET['lang']);
else
	$translate = new Translator('en');
?>
<?php $title="Forgot Password";?>
<?php require("assets/wrapper/login_header.php"); ?>


<?php // echo $row_forgot_password['password']; ?><?php //echo $row_forgot_password['email']; ?>


<form name="forgot" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<p><label for="username"><?php echo $translate->__('Username:');?></label>
<input name="username" type="text" value="" />
</p>
<input type="submit" name="submit" value="<?php echo $translate->__('Request');?>"/>
<input type="reset" name="reset" value="<?php echo $translate->__('Reset');?>"/>
</form>
<?php
if(isset($_POST['submit']))
{
//mysql_connect("localhost", "**", "**") or die(mysql_error());
//mysql_select_db("**") or die(mysql_error());

$username = $_POST['username'];
$sql="SELECT * FROM members WHERE username = '$username'";
$query = mysql_query($sql);

if(!$query) 
    {
    die(mysql_error());
    }
    
if(mysql_affected_rows() != 0)
    {
$row_forgot_password=mysql_fetch_array($query);
$password=$row_forgot_password["password"];
$email=$row_forgot_password['email'];
$subject="your password";
$header="from:you@yourdomain.com";
$content="your password is ".$password;
mail($email, $subject, $content, $header);
//mail($email, $subject, $header);
print $translate->__('Your Password has been emailed to you.');
    }
else 
    {
    echo $translate->__('No such user exists.');
    }
}
?>


<!--<form action="" method="get" name="forgotpass">

<input name="email" type="text">
<input name="submit" type="submit" value="Send">

</form>-->




<?php require("assets/wrapper/login_footer.php"); ?>







<?php
mysql_free_result($forgot_password);
?>
