<%
# $Id: forgot-password.php,v 1.5 2005/04/10 02:02:01 hirokai Exp $
include( "../modules/utils.inc.php" );
include( "$modules/header.inc.php" );
$showForm = true;
$messages = "";
if( $userId || $email ) {
mysql_connect();
mysql_selectdb( getDBName() );
if( $userId ) {
# check for id
$qs = "SELECT * FROM linksUsers WHERE userid = '" . urlencode( $userId ) . "';";
} else {
$qs = "SELECT * FROM linksUsers WHERE email = '" . urlencode( $email ) . "';";
}
$q = mysql_query( $qs );
$numRows = mysql_num_rows($q);
if( $numRows == 1 ) {
$email = urldecode( mysql_result($q,$i,"email"));
$userId = urldecode( mysql_result($q,$i,"userId"));
$password = urldecode( mysql_result($q,$i,"password"));
$showForm = false;
$from = "hide@address.com";
$subject = "Your Feed Me Links password";
$headers = "";
$headers .= "From: Feed Me Links <$from>\n";
$headers .= "X-Mailer: feedmelinks-mailer-daemon\n";
$body = "Hello!
Your feedmelinks user name is: $userId.
Your feedmelinks password is: $password
Thanks,
-- the Feed Me Links crew";
$mailSuccess = mail( $email, $subject, $body, $headers);
#echo "mailSuccessL $mailSuccess<br />";
$messages = "emailing your password to " . ( $userId ? "$userId's email address" : $email ) . "...<br /><h2>Email sent!</h2>";
} else {
$label = $userId ? "username" : "email address";
$messages = "That $label was not found. Please check your spelling<br />(and make sure that you still exist.)";
}
}
%>
<title> Feed Me My Password, Dammit! </title>
<% if( $messages ) { %>
<div class="reminderBox" style="width: 400px; margin-top: 10px;">
<%= $messages %>
</div>
<% } %>
<% if( $showForm ) { %>
<br />
<br />
<div class="reminderBox" style="width: 400px;">
<form action="/misc/forgot-password">
<%= tell( "Forget your password?", "No worries! We'll email it to you..." ) %>
<table width="450" border="0">
<tr>
<td align="right">
<b>Just enter your username: </b>
</td>
<td>
<input type="text" name="userId" maxLength="16" value="<%= $userId %>" />
</td>
</tr>
<tr>
<td align="right">
<b>...or email address: </b>
</td>
<td>
<input type="text" name="email" maxLength="64" value="<%= $email %>" /><br />
</td>
</tr>
<tr>
<td>
</td>
<td>
<br />
<input type="submit" value=" Email my Password " class="button" />
</td>
</tr>
</table>
<br clear="all" />
<br />
</form>
</div>
<% } %>
<% include( "$modules/footer.inc.php" ); %>