Ok, I am fairly new to php, but have been doing Visual Basic and C++ for years so I have the theories and pricipals of programming down pretty good.
I am having two problems with this page that are driving me NUTS. I have looked and looked, tried and tried but can not seem to find the problem.
The php page is a lost password utility for a website I am designing. The first problem is that when the page first appears, it displays every record in the database. This is done because I have used echo to display the results of my query, but even if I didn't echo the results it would still be pulling every record to begin with. I need it to not make any query until the "Submit" button is clicked.
The second problem is that it will not mail the password to the user, who's email address is the vaiable $uemail. That vaiable is retrived from a text box on the form that is filled in by the user. The form then should query the database looking for anyone with that email address and email the required information back to the user at that email address.
Can someone help me and tell me what I am doing wrong?
--- Start of PHP Code ---
<html>
<head>
<title>Find Password</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
td{
font-family:arial;
font-size:8pt;
color:#696969;
}
.wh{
color:white;
}
.more{
color:#0974A6;
}
.menu{
color:#748B3D;
}
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="60%" border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td colspan="3">
<div align="center"></div>
</td>
</tr>
<tr>
<td width="17%">
<div align="left"><img src="../../images/GLTA-logo-new.gif" width="120" height="98"></div>
</td>
<td width="62%">
<div align="center"><b><font color="#000000">Please note that if you have
not set up your Password Retrieval Profile, which includes providing your
e-mail address, you will not be able to use this feature.</font></b></div>
</td>
<td width="21%"><img src="../../images/GLTA-logo-new.gif" width="120" height="98"></td>
</tr>
<tr>
<td colspan="3" height="11"> </td>
</tr>
</table>
<form name="form1" >
<table width="342" border="1" cellspacing="3" cellpadding="3" bordercolor="#333333" align="center">
<tr align="center" bgcolor="A5E2FF">
<td colspan="2"><font face="Tahoma"><b><font color="#FF0000">Retrieve Account
Information</font></b></font></td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="224" bgcolor="#FFFFCC">
<input type="text" name="uemail" size="30" value="Type your email address here">
</td>
<td width="118" bgcolor="#FFFFCC">
<input type="submit" name="Submit" value="Find Account">
</td>
</tr>
</table>
</form>
<table width="40%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<div align="center"><b><font color="#000000">Click <a href="../login.php" target="_self">here</a>
to go back to the login screen.</font></b> </div>
</td>
</tr>
</table>
<?
@mysql_connect('**', '', '') or die(mysql_error());
@$result = mysql_list_tables('**') or die(mysql_error());
$sql = "SELECT * FROM authuser WHERE email = '$uemail'";
@$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
while ($row = mysql_fetch_row($result)) {
// $tb_names[] = $row[0];
// echo "System ID: ";
// echo $row[0].'<br />';
echo "First Name: ";
echo $row[8].'<br />';
echo "Last Name: ";
echo $row[9].'<br />';
echo "User Group: ";
echo $row[3].'<br />';
echo "Status: ";
echo $row[5].'<br />';
echo "Username: ";
echo $row[1].'<br />';
echo "Password: ";
echo $row[11].'<br />';
// echo "Encrypted Password: ";
// echo $row[2].'<br />';
// echo "Level: ";
// echo $row[4].'<br />';
// echo "Last Logon: ";
// echo $row[6].'<br />';
// echo "Logon Count: ";
// echo $row[7].'<br />';
echo "E-Mail Address: ";
echo $row[10].'<br />';
$username = $row[1];
$firstname = $row[8];
$lastname = $row[9];
$password = $row[11];
$email = $row[10];
$group = $row[3];
$status = $row[5];
$uemail = $row[10];
}
$msubject = "Account information from GLTA";
$mbody .= "The account information you requested is displayed below.\n";
$mbody .= "\n";
$mbody .= "Username\t\t: $username \r\n";
$mbody .= "Password\t\t: $password \r\n";
$mbody .= "E-Mail\t\t: $email \r\n";
$mbody .= "User Group\t\t: $group \r\n";
$mbody .= "Access Level\t\t: $level \r\n";
$mbody .= "Status\t\t: $status \r\n";
$mheader = "From: GLTA Security";
$to = "$uemail <$uemail>";
$headers = "From: \"".addslashes($uemail)."\" <".$uemail.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n";
mail( $to, $msubject, $mbody, $headers ) or print "Error handling message. message not sent.";
?>
The email to <?=$to?> (<?=$to?> ) Was send successfully.<br><br>
The message was: <?=$mbody?><br><br>
And the headers were: <?=$headers?>
</body>
</html>
--- End of PHP Code ---