The script:
<form name="forgot" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<p><label for="username">Username:</label>
<input name="username" type="text" value="" />
</p>
<input type="submit" name="submit" value="submit"/>
<input type="reset" name="reset" value="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 `email` FROM `login` WHERE `username` ='.$username.'";
$query = mysql_query($sql);
if(!$query)
{
die(mysql_error());
}
if(mysql_affected_rows() != 0)
{
$row=mysql_fetch_array($query);
$password=$row["password"];
$email=$row["email"];
$subject="your password";
$header="from:you@yourdomain.com";
$content="your password is ".$password;
mail($email, $subject, $row, $header);
print "An email containing the password has been sent to you";
}
else
{
echo("no such login in the system. please try again.");
}
}
?>
The problem:
The script is not working. When I enter a working registered username it displays the echo statement no such login no matter what. My config info is correct. I have a table login with the fields username and password and checked for spelling. Any ideas why this isn't working?
Thanks in advance