PDA

View Full Version : forget password script


0810
11-12-2002, 10:36 PM
hi how are you doing?

I try to run this script whihc is forget password.

Let's say one forgets his password. and then he typed his e-mail in my form. And He will get password in his e-mail.

my script is not working. Could you check it out for me

my php is 4.23

here is my script


<?php if(isset($_POST["formSubmitted"]=="yes"))

{

$con=mysql_connect("localhost,","itohideo_hide","0810") or die("can't connect");
$db=mysql_select_db("itohideo_japan",$con) or die("can't find your database");


$password=$_POST["password"];
$mail=$_POST["mail"];

$sql="select password from kk where mail='$mail' ";
$result=mysql_query($sql,$con) or die("couldn't execute query");


if(mysql_num_rows($result)==0){

echo"your E-mail is incorrect. Please try again.";


}


if($row=mysql_fetch_array($result)==$mail)
{

$pssword=$_POST["password"];
$subject=$_POST["subject"];
$msg=$_POST["msg"];

$subject="Your password from itohideo.com";
$msg="Here is the password. Do not forget it!";



mail($password, $subject, $msg);


echo "<center>Thank you. You will get password in your e-mail.";
}


}

?>

<html>
<body>
Forget Password:
<form actoin="<?php $_SERVER['PHP_SELF'];?>" method="post">
E-mail Address:<input type="text" size="30" name="mail">
<input type="submit" name="submit" value="submit"><input type='hidden' name='formSubmitted' value='yes'><br>
<input type="button" name="reset" value="reset"><br>
</form>

</body>
</html>

Nightfire
11-12-2002, 11:20 PM
From what I can see, you're trying to send an email to the password

mail($password, $subject, $msg);

Use:

$msg = "Here is the password. Do not forget it! $password";

mail($mail, $subject, $msg);

Also got a typo here

$password=$_POST["password"];

0810
11-13-2002, 04:58 AM
I fixed like this but not working now.
could you tell me what is wrong.

thanks

here is code

myphp is 4.23



<html>
<head>
<title>Forgot your password?</title>
</head>
<body>

<?php

if( isset($_POST["formSubmitted"]) )

{

$con = mysql_connect("localhost","itohideo_hide","0810") or die("can't connect");
$db = mysql_select_db("itohideo_japan",$con) or die)("can't find your database");

$mail = $_POST["mail"];

$sql="SELECT password FROM kk WHERE mail = '" . $mail . "'";
$result = mysql_query($sql);

if(mysql_num_rows($result) == 0)

{

echo("your E-mail is incorrect. Please try again.") ;

}

else

{

$password = $result;
$subject = 'Your password for itohideo.com';
$msg = "Your password is: $result";

mail($mail, $subject, $msg, "FROM: webmaster@itohideo.com");

echo("Thank you. You will get password in your e-mail.");

}


}

?>
<br /><br />
Forget Password:
<form actoin="<?php $_SERVER['PHP_SELF'];?>" method="post">
E-mail Address:<input type="text" size="30" name="mail">
<input type="submit" name="submit" value="submit"><input type='hidden' name='formSubmitted' value='yes'><br>
<input type="button" name="reset" value="reset"><br>
</form>

</body>
</html>

Nightfire
11-13-2002, 08:52 AM
$password = $_POST['password'];
$subject = 'Your password for itohideo.com';
$msg = "Your password is: $password";

mail($mail, $subject, $msg, "FROM: webmaster@itohideo.com");

echo("Thank you. You will get password in your e-mail.");