Jump to content
MakeWebGames

Recommended Posts

Posted

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]";
?>
Posted

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

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...