DJ Rankin Posted August 6, 2007 Share Posted August 6, 2007 hi iv got this code on here its forgot pass but its not sending it to my email please help me +6 <?php /*----------------------------------------------------------- -- William -- Password reset ------------------------------------------------------------*/ require "mysql.php"; require "global_func.php"; global $c; print " YOUR GAME NAME Forgot Password [img=logo.png]"; if($_GET['action'] == '') { print "Your Username (game name): [url='login.php']>back[/url]"; } if($_GET['action'] == 'submit') { if(!$_POST['username']) { die("You forgot to enter your username!"); } else { $a=mysql_query("SELECT * FROM users WHERE username='{$_POST['username']}'",$c) or die(mysql_error()); $b=mysql_fetch_array($a); if (mysql_num_rows($a)==0) { print "This user does not exist Back"; exit; } $key=randomString(10); mysql_query("INSERT INTO passreset VALUES ('','$key','{$b['userid']}','2');",$c) or die(mysql_error()); $to = $b['email']; $subject = "american-wars"; $headers = "From: [email][email protected][/email]"; $body = "Hello {$b['username']}! To reset you password goto http://americanwars.onlinewebshop.net/passreset.php?key=$key&ID={$b['userid']} NOTE: This link is only active for 2 days!"; @$send = mail($to, $subject, $body, $headers); print "Password reset sent to your e-mail! NOTE:The link is only active for 2 days! [url='login.php']back[/url]"; } } ?> <?php /*----------------------------------------------------------- -- William -- Password reset ------------------------------------------------------------*/ require "mysql.php"; require "global_func.php"; global $c; print " american-wars Forgot Password [img=logo.png]"; if($_GET['ID'] == 0) { die("Invalid userid"); } if(!$_GET['key']) { die("Just go now"); } $key=$_GET['key']; $a=mysql_query("SELECT * FROM `passreset` WHERE `key`='$key' AND userid={$_GET['ID']}",$c) or die(mysql_error()); if (mysql_num_rows($a)==0) { print "Invalid key, please try again Back"; exit; } $b=mysql_fetch_array($a); $tt=mysql_query("SELECT * FROM users WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); $gh=mysql_fetch_array($tt); $random=$_GET['key']; mysql_query("DELETE FROM passreset WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); mysql_query("UPDATE `users` SET userpass=md5('{$_GET['key']}') WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); print "Your new password has been mailed to you, use this to log in and then change it in the preferences."; $to = $gh['email']; $subject = "Forgot Password - american-wars"; $headers = "From: [email][email protected][/email]"; $body = "Hello {$gh['username']}! Your new password is $random log in with this password and change it in the preferences menu."; $send = @mail($to, $subject, $body, $headers); print "Password sent to your e-mail! [url='login.php']back[/url]"; ?> Quote Link to comment Share on other sites More sharing options...
Silver Posted August 6, 2007 Share Posted August 6, 2007 Re: HELP URNGETLY!!!!!!!!!!!!! <?php /*----------------------------------------------------------- -- William -- Password reset ------------------------------------------------------------*/ require "mysql.php"; require "global_func.php"; global $c; print "<html> <head> <title>american-wars Forgot Password</title> <style> body { font-family:Verdana;font-size:8pt;color: black;background: #C3C3C3; } .details { border: 2px dashed red; background: #F88;width:50%;height=120; } .details table,tr,td { font-size:10pt;border: 1px solid white; } .logo img { border: none; } a { text-decoration: none; } </style> </head> <body><center><div class=logo>[img=logo.png]</div>"; if($_GET['ID'] == 0) { die("Invalid userid"); } if(!$_GET['key']) { die("Just go now"); } $key=$_GET['key']; $a=mysql_query("SELECT * FROM `passreset` WHERE `key`='$key' AND userid={$_GET['ID']}",$c) or die(mysql_error()); if (mysql_num_rows($a)==0) { print "Invalid key, please try again <a href=forgot_password.php>Back</a>"; exit; } $b=mysql_fetch_array($a); $tt=mysql_query("SELECT * FROM users WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); $gh=mysql_fetch_array($tt); $random=$_GET['key']; mysql_query("DELETE FROM passreset WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); mysql_query("UPDATE `users` SET userpass=md5('{$_GET['key']}') WHERE userid={$_GET['ID']}",$c) or die(mysql_error()); print "Your new password has been mailed to you, use this to log in and then change it in the preferences."; $to = $gh['email']; $subject = "Forgot Password - american-wars"; $headers = "From: [email][email protected][/email]"; $body = "Hello {$gh['username']}! Your new password is $random log in with this password and change it in the preferences menu."; mail($to, $subject, $body, $headers); print "Password sent to your e-mail! [url='login.php']back[/url]"; ?> should work Quote Link to comment Share on other sites More sharing options...
DJ Rankin Posted August 6, 2007 Author Share Posted August 6, 2007 Re: HELP URNGETLY!!!!!!!!!!!!! Fatal error: Call to undefined function: randomstring() in /home/www/.................net/forgot_password.php on line 43 Quote Link to comment Share on other sites More sharing options...
YoungGold Posted August 7, 2007 Share Posted August 7, 2007 Re: HELP URNGETLY!!!!!!!!!!!!! DJ Ranking stop pming me if i new how to fix it i would inform you. Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted August 7, 2007 Share Posted August 7, 2007 Re: HELP URNGETLY!!!!!!!!!!!!! Did you add this function randomString($length) { $string = md5(time()); $highest_startpoint = 32-$length; $randomString = substr($string,rand(0,$highest_startpoint),$length); return $randomString; } at the bottom of global_func.php? Quote Link to comment 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.