Forgot password help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Forgot password help

Post by Smackie »

I made a forgot password script in this code its suppose to send out the username and password if the username and email address is matched up well it matches them up but when it sends i get an error and when it goes to there inbox it say from Nobody and subject is Password and user in the email it shows....

username:
password:

but there isnt anything in there

here is the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/haunted/public_html/The_Bored_Game/forgotpassword.php on line 14
line 14
$query = mysql_query($sql);

how can i make it where the it comes from my email address and in the email it would be like

Here is your username and password if you didnt request it dont worry your username and password only goes to your email box..

username: username
password: password


you requested the email from http://blah.com
here is the script...

Code: Select all

<?php
if($go == "1")
{
mysql_connect("localhost","haunted_smackie","*******");
mysql_select_db(haunted_BoringGame);

$sql = @mysql_query("SELECT * FROM dbUsers WHERE username='$name' && email='$email' ");
if(!$sql)
{
echo "The user name and email do not match.";
exit;
}
$query = mysql_query($sql);
$fPass = mysql_fetch_array($query);

mail($email, "Your Password", "User Name: ". $fPass[username] ."\nPassword: ". $fPass[password]);
echo "Your Password has been sent to ". $email .".";
}
?>
<form action="<?= $PHP_SELF ?>" method="post">
Name: <input type="text" name="name" size="24" border="0"><br>
E-mail: <input type="text" name="email" size="24" border="0"><br>
<input type="hidden" name="go" value="1" border="0"><input type="submit" name="submitButtonName" border="0">
</form>
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

in your mysql_select_db you sho uld have quotes around haunted_BoringGame and also after $sql put or die(mysql_error());

also i dont see the point of your $query because its already queired in $sql,i think that may error also and if you want your emails to be accepted by yahoo and such you should check the php.net mail script with the proper headers
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Smackie wrote:its suppose to send out the username and password if the username and email address is matched up.
Well, from security's point of view, you aren't supposed to send out the passwords through plain emails... since they may have used it somewhere else also. select any randomly-generated string for password and mail them that so that they can change their passwords after logging in with that one.
Post Reply