I am trying to create a php page to email a user their password if they forget it. i know that i should have several security features involved with determining if the user is actually who they say they are, however i reckon that starting basic will be the best way. i cant seem to email anything to myself at my email address at the moment, and i reckon if i can get anything to be sent from my mysql database to my email address, it would be a start.
the table in mysql dbase is: member
my email address is: brockie99@talk21.com
here is the code i have already:
<form action="ForgotPassword.php" method="post">
<tr>
<td><p class="password" align="center">Please enter your username: </p></td>
<td><input type="text" size="35" name="username"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><p align="right">(Click here to send password to email address)</p></td>
<td align="center"><input type="submit" name="mailpassword" value="Send"></td>
</tr>
</form>
</table>
<?php
/*if ($mailpassword)
{
$db = mysql_connect("localhost", "the-coff", "frog66");
mysql_select_db("the-coff_maitland",$db);
$select = mysql_query("SELECT password, username FROM member WHERE username LIKE '$username';", $db) or die(mysql_error());
while ($myrow = mysql_fetch_array($select))
{
mail($username, "Password Reminder", "Here is your password: "$password, "From: Maitland Medical");
}*/
if ($_POST['submitted'] == 'yes')
{
$username = $_POST['username'];
$db = mysql_connect("localhost", "*******", "*******");
mysql_select_db("the-coff_maitland",$db);
$select = mysql_query("SELECT password, username FROM member WHERE username = '$username';", $db) or die(mysql_error());
if (mysql_num_rows($select) < 1)
{
die("Couldn't find username: $username.");
}
echo $username;
$myrow = mysql_fetch_array($select);
mail($username, "Password Reminder", 'Here is your password: ' . $myrow['password'], "From: Maitland Medical <info@maitlandmedical.co.uk>");
}
?>
Remember that i am trying to simply email the password first, as i cannot even get anything to email to my email address.