hunter_li Posted December 25, 2007 Share Posted December 25, 2007 I need a Jmail forgot password script, many of our members have forgotten their password. I had some scripts, but it need SMTP service, the virtual-space doesn't support SMTP service ,i can't send password to the member. will you have jmail forgot password script? help me, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/ Share on other sites More sharing options...
hunter_li Posted December 25, 2007 Author Share Posted December 25, 2007 Mysql detail: tb_users (username password ip email country) Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-422767 Share on other sites More sharing options...
redarrow Posted December 25, 2007 Share Posted December 25, 2007 in this situation ask the user to provide secure information and output there new password via the web site....... the only reason i say provide via website as stated no email sending..... Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-422789 Share on other sites More sharing options...
redarrow Posted December 25, 2007 Share Posted December 25, 2007 There you go this will change the users password to a new one. and show it on the current page...... this will ony work if the user nows there current username and email address....... the code will see if the user exists then chage the password with a numiric number then echo there new details out..... <?php session_start(); // database connection..... if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; $sql="SELECT * from `what_ever` where `userna me`='$username' AND `email`='$email'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if( ($x['username']) && ($x['email']) > 1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass=(md5($_POST['new_pass'])); $sql2="UPDATE `what_ever` set `password`='$new_pass' WHERE `username`='$username' AND `email`='$email'"; $sql2=mysql_query($sql2) or die(mysql_error()); echo "<br><br> Your new ".$x['username']." password <br><b> Username: ".$x['username']." <br><br> Password: ".$_SESSION['new_pass']." <br><br> Please try to remember your new password cheers! <br><br> or change your password in your members area to a easy remembered password"; }else{ echo" Sorry we have no record of your username or email <br><br> please join our website <br><br> <a href='join.php'>join now!<a>"; exit; } } } ?> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF'] ?>"> <h1>Password recovery</h1> <br> Please provide username: <br><br> <input type="text" name="username"> <br><br> Please provide email address: <br><br> <input type="text" name="email"> <br><br> <input type="submit" value="Send"> </form> </center> Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-422800 Share on other sites More sharing options...
hunter_li Posted December 25, 2007 Author Share Posted December 25, 2007 thanks redarrow, but it still doesn't work ,what's wrong with it ? code: <?php session_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password="mypassword"; // Mysql password $db_name="hunterli"; // Database name //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; $sql="SELECT * FROM tb_users WHERE username='$username' and email='$email'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if( ($x['username']) && ($x['email']) > 1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass=(md5($_POST['new_pass'])); $sql2="UPDATE tb_users set password='$new_pass' WHERE username='$username' AND email='$email'"; $sql2=mysql_query($sql2) or die(mysql_error()); echo "<br><br> Your new ".$x['username']." password <br><b> Username: ".$x['username']." <br><br> Password: ".$_SESSION['new_pass']." <br><br> Please try to remember your new password cheers! <br><br> or change your password in your members area to a easy remembered password"; }else{ echo" Sorry we have no record of your username or email <br><br> please join our website <br><br> <a href='login.php'>join now!<a>"; exit; } } } ?> <center> <form method="POST" action="<?php $_SERVER["PHP_SELF"] ?>"> <h1>Password recovery</h1> <br> Please provide username: <br><br> <input type="text" name="username"> <br><br> Please provide email address: <br><br> <input type="text" name="email"> <br><br> <input type="submit" value="Send"> </form> </center> Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423055 Share on other sites More sharing options...
teng84 Posted December 25, 2007 Share Posted December 25, 2007 what is the error now? Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423057 Share on other sites More sharing options...
Northern Flame Posted December 26, 2007 Share Posted December 26, 2007 this should work: <?php session_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password="mypassword"; // Mysql password $db_name="hunterli"; // Database name //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; $sql="SELECT * FROM tb_users WHERE username='$username' and email='$email'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if( ($x['username']) && ($x['email']) > 1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass= md5($_SESSION['pass']); $sql2="UPDATE tb_users set password='$new_pass' WHERE username='$username' AND email='$email'"; $sql2=mysql_query($sql2) or die(mysql_error()); echo " Your new ".$x['username']." password Username: ".$x['username']." Password: ".$_SESSION['pass']." Please try to remember your new password cheers! or change your password in your members area to a easy remembered password"; }else{ echo" Sorry we have no record of your username or email please join our website <a href='login.php'>join now!<a>"; exit; } } } ?> <center> <form method="POST" action="<?php $_SERVER["PHP_SELF"] ?>"> <h1>Password recovery</h1> Please provide username: <input type="text" name="username"> Please provide email address: <input type="text" name="email"> <input type="submit" value="Send"> </form> </center> // I just edited it again, now try Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423108 Share on other sites More sharing options...
hunter_li Posted December 26, 2007 Author Share Posted December 26, 2007 what is the error now? after input username, password ,it doesn't display new password even an error message . display img: Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423262 Share on other sites More sharing options...
redarrow Posted December 26, 2007 Share Posted December 26, 2007 advance thank you the code currenly works fine updates database but the else dosent work just dosent echo the message out well weried..... <?php session_start(); // //CREATE TABLE `database_test`.`pass` ( //`id` SMALLINT( 5 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY , //`username` VARCHAR( 25 ) NOT NULL , //`password` VARCHAR( 35 ) NOT NULL , //`email` VARCHAR( 50 ) NOT NULL //) ENGINE = InnoDB // $db=mysql_connect("xxx","xxxxx","xxxx"); $db_result=mysql_select_db("database_test",$db); if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; if(empty($username)||(empty($email))){ echo"<center> <font color='red'>Please fill in all the form!</font></center>"; unset($_SESSIOM['pass']); } $sql="SELECT * from pass where username='$username' AND email='$email' and id='00001'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if( ($x['email']) || ($x['username']) == 1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass=(md5($_POST['new_pass'])); $sql2="UPDATE pass set password='$new_pass' WHERE username='$username' AND email='$email' and id='00001'"; $result2=mysql_query($sql2) or die(mysql_error()); echo "<br><br> Your new ".$x['username']." password <br><b><br><br> Username: ".$x['username']." <br><br> Password: ".$_SESSION['pass']." <br><br> Please try to remember your new password cheers! <br><br> or change your password in your members area to a easy remembered password"; unset($_SESSIOM['pass']); exit; }else{ echo" Sorry we have no record of your username: $username or email: $email <br><br> please join our website <br><br> <a href='join.php'>join now!<a>"; unset($_SESSIOM['pass']); exit; } } } ?> <center> <form method="POST" action=" "> <h1>Password recovery</h1> <br> Please provide username: <br><br> <input type="text" name="username"> <br><br> Please provide email address: <br><br> <input type="text" name="email"> <br><br> <input name="submit" type="submit" value="Send"> </form> </center> Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423404 Share on other sites More sharing options...
redarrow Posted December 26, 2007 Share Posted December 26, 2007 why dosent the else work on this new rewritten code please.. i addaed the mysql_num_rows but the else dosent still work any idears plese... <?php session_start(); // //CREATE TABLE `database_test`.`pass` ( //`id` SMALLINT( 5 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY , //`username` VARCHAR( 25 ) NOT NULL , //`password` VARCHAR( 35 ) NOT NULL , //`email` VARCHAR( 50 ) NOT NULL //) ENGINE = InnoDB // $db=mysql_connect("xxx","xxx","xxxx"); $db_result=mysql_select_db("database_test",$db); if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; if(empty($username)||(empty($email))){ echo"<center> <font color='red'>Please fill in all the form!</font></center>"; } $sql="SELECT * from pass where username='$username' AND email='$email' and id='00001'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if(mysql_num_rows($sql_result)==1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass=(md5($_POST['new_pass'])); $sql2="UPDATE pass set password='$new_pass' WHERE username='$username' AND email='$email' and id='00001'"; $result2=mysql_query($sql2) or die(mysql_error()); echo "<br><br> Your new ".$x['username']." password <br><b><br><br> Username: ".$x['username']." <br><br> Password: ".$_SESSION['pass']." <br><br> Please try to remember your new password cheers! <br><br> or change your password in your members area to a easy remembered password"; unset($_SESSIOM['pass']); exit; }else{ echo" Sorry we have no record of your username: $username or email: $email <br><br> please join our website <br><br> <a href='join.php'>join now!<a>"; exit; } } } ?> <center> <form method="POST" action=" "> <h1>Password recovery</h1> <br> Please provide username: <br><br> <input type="text" name="username"> <br><br> Please provide email address: <br><br> <input type="text" name="email"> <br><br> <input name="submit" type="submit" value="Send"> </form> </center> Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423413 Share on other sites More sharing options...
hunter_li Posted December 26, 2007 Author Share Posted December 26, 2007 why dosent the else work on this new rewritten code please.. i addaed the mysql_num_rows but the else dosent still work any idears plese... <?php session_start(); // //CREATE TABLE `database_test`.`pass` ( //`id` SMALLINT( 5 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY , //`username` VARCHAR( 25 ) NOT NULL , //`password` VARCHAR( 35 ) NOT NULL , //`email` VARCHAR( 50 ) NOT NULL //) ENGINE = InnoDB // $db=mysql_connect("xxx","xxx","xxxx"); $db_result=mysql_select_db("database_test",$db); if($_POST['submit']){ $username=$_POST['username']; $email=$_POST['email']; if(empty($username)||(empty($email))){ echo"<center> <font color='red'>Please fill in all the form!</font></center>"; } $sql="SELECT * from pass where username='$username' AND email='$email' and id='00001'"; $sql_result=mysql_query($sql)or die(mysql_error()); while($x=mysql_fetch_assoc($sql_result)){ if(mysql_num_rows($sql_result)==1){ $new_pass=rand(0,123456); $_SESSION['pass']=$new_pass; $new_pass=(md5($_POST['new_pass'])); $sql2="UPDATE pass set password='$new_pass' WHERE username='$username' AND email='$email' and id='00001'"; $result2=mysql_query($sql2) or die(mysql_error()); echo "<br><br> Your new ".$x['username']." password <br><b><br><br> Username: ".$x['username']." <br><br> Password: ".$_SESSION['pass']." <br><br> Please try to remember your new password cheers! <br><br> or change your password in your members area to a easy remembered password"; unset($_SESSIOM['pass']); exit; }else{ echo" Sorry we have no record of your username: $username or email: $email <br><br> please join our website <br><br> <a href='join.php'>join now!<a>"; exit; } } } ?> <center> <form method="POST" action=" "> <h1>Password recovery</h1> <br> Please provide username: <br><br> <input type="text" name="username"> <br><br> Please provide email address: <br><br> <input type="text" name="email"> <br><br> <input name="submit" type="submit" value="Send"> </form> </center> thank you , but this part still can not display : echo" Sorry we have no record of your username: $username or email: $email <br><br> please join our website <br><br> <a href='join.php'>join now!<a>"; Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-423522 Share on other sites More sharing options...
hunter_li Posted December 27, 2007 Author Share Posted December 27, 2007 it is more safe to send emails to members include their password . i need a jmail script. Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-424160 Share on other sites More sharing options...
hunter_li Posted December 29, 2007 Author Share Posted December 29, 2007 Guys,give some suggestion please. Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-425093 Share on other sites More sharing options...
redarrow Posted December 29, 2007 Share Posted December 29, 2007 ken solved my problam so you now have your code. http://www.phpfreaks.com/forums/index.php/topic,174720.0.html Quote Link to comment https://forums.phpfreaks.com/topic/83108-solved-help-me-please-i-have-trouble-in-forgot-password-scrpt/#findComment-425309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.