I've create a page that lists all new users who have not yet been approved. To approve I check a checkbox which updates the database. This works fine. The problem is that the script should also e-mail the userid and password to the newly approved user. It does not. Instead I keep getting a Bad Destination error.
Here 's the code:
This part works fine.
<?php
// generate and execute query list news
$qryListNotApprovedUsers = "SELECT ID,UserID,FullName,Email,RegistrationDate,Password
FROM tblUsers
WHERE fk_StatusID = '0'";
$rsltListNotApprovedUsers = mysql_query($qryListNotApprovedUsers) or die ("Error in query: $qryListNotApprovedUsers. " . mysql_error());
// if records present
if (mysql_num_rows($rsltListNotApprovedUsers) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while($ListNotApproved_row = mysql_fetch_object($rsltListNotApprovedUsers))
{
$cellcolor = ($i++ & 1) ? '#eeeeee' : '#ffffff';
{
echo
"
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
<input type=\"hidden\" name=\"id\" value=\"".$ListNotApproved_row->ID."\">
<tr class=\"intro\">
<td width=\"142\"height=\"19\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\">".$ListNotApproved_row->UserID."</td>
<td width=\"6\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\"></td>
<td width=\"182\" width=\"155\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\">".$ListNotApproved_row->FullName."</td>
<td width=\"8\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\"></td>
<td width=\"227\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\">".$ListNotApproved_row->Email."</td>
<td width=\"4\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\"></td>
<td width=\"250\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\">".formatDate($ListNotApproved_row->RegistrationDate)."</td>
<td width=\"6\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\"></td>
<td width=\"119\" align=\"left\" valign=\"top\" bgcolor=\"".$cellcolor."\"><input type=\"checkbox\" name=\"status\" value=\"1\"></td>
</tr>
</table>
"
;
}
}
}
?>
This part does not work.
<?PHP
else:
// Process update
dbConnect('database');
$sql = "UPDATE tblUsers
SET fk_StatusID = '$status'
WHERE ID = '$id'";
$result = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error());
if ($status == '1')
// Email the userid/password to the person.
$message = "G'Day!
Your personal account for the Project Web Site has been created! To log in, proceed to the following address:
http://www.mydomain.com/
Your personal login ID and password are as follows:
userid: $UserID
password: $Password
You aren't stuck with this password! Your canchange it at any time after you have logged in.
If you have any problems, feel free to contact me at <me@myhost.com>.
-Steve Fitzgerald
";
mail($ListNotApproved_row->Email,"Your Password for the Project Website",
$message, "From:Steve Fitzgerald <sf@mnetsys.com>");
?>
It appears that the proper e-mail is not being passed.
I could use some help.
Thanks.