Jump to content

Forgotten passwrod script


dannybeales

Recommended Posts

hey people, i have a problem on my game that my lost password script refuses to send the activation email here is the code:

 

<?php 
include_once("config.php");
include_once("connect.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Forgot Password.</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="800" border="0" align="center" cellspacing="0">
  
  <tr>
    <td><table border="0" align="center" cellspacing="2">
      <tr>
        <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='index.php'"><a href="index.php" onFocus="if(this.blur)this.blur()">Login.</a></td>

        <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='register.php'"><a href="register.php" onFocus="if(this.blur)this.blur()">Register.</a></td>

     <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='tos.php'">
<a href="tos.php" onFocus="if(this.blur)this.blur()">Terms of service.</a></td>






        </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle"><form method="post">
      <br />
  <table width="350" border="0" align="center" cellspacing="0">
    <tr>
      <td colspan="2" align="center">
  <?php 
  
  include_once("config.php");
include_once("connect.php");
  
  if(isset($_POST['Submit'])){
  
  $sql = "SELECT status FROM sitestats WHERE id='1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$page_status = htmlspecialchars($row->status);
$page_status_array = explode("-", $page_status);

if(!empty($page_status_array[33])){
echo htmlspecialchars(stripslashes($page_status_array[33]));
}else{
  
  $nsql = "SELECT mail,name FROM login WHERE name='".mysql_real_escape_string($_POST['name'])."'";
$query = mysql_query($nsql) or die(mysql_error());
$row = mysql_fetch_object($query);
$name = htmlspecialchars($row->name);
$mail = htmlspecialchars($row->mail);
  
  if((empty($_POST['name'])) or (empty($_POST['mail']))){
  echo "You left one or more fields empty.";
  }else{
  
  if(empty($name)){
  echo "Invalid information.";
  }else{
  
  if($_POST['mail'] != $mail){
  echo "Invalid information.";
  }else{
  
  for ($i = 0; $i < 10; $i++) {
$pnum[$i] = rand(0,9);
}

$new_pass = "$pnum[0]$pnum[1]$pnum[2]$pnum[3]$pnum[4]$pnum[5]$pnum[6]$pnum[7]$pnum[8]$pnum[9]";
  
  $bericht  = "Your password has been Reset. Please change it to your own ASAP.\n\n";
      $bericht .= "Password: ".$new_pass."\n";
  $bericht .= "Special Execution Password: ".$new_pass."\n";
      $mail = mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">");
  
  $new_pass = md5($new_pass);
  $result = mysql_query("UPDATE login SET password='".$new_pass."', login_count='0' WHERE name='" .mysql_real_escape_string($name). "'") 
or die(mysql_error());
  
  echo ""Password: ".$new_pass."\n";";

	}// if invalid email.
	}// if invalid name
  	}// if empty field.
	}// if dissabled.
  	}// if isset.
  ?>	  </td>
    </tr>
    <tr>
      <td width="75" align="left">Username:</td>
      <td width="275" align="center"><input name="name" type="text" class="entryfield" id="name" style='width: 95%;' size="20"/></td>
    </tr>
    <tr>
      <td width="75" align="left">Email:</td>
      <td width="275" align="center"><input name="mail" type="text" class="entryfield" id="mail" style='width: 95%;'/></td>
    </tr>
    <tr>
      <td colspan="2"><table width="100" border="0" align="right" cellspacing="0">
          <tr>
            <td align="center"><input name="Submit" type="submit" class="button" value="Submit"onfocus="if(this.blur)this.blur()" /></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form></td>
  </tr>
</table>
</body>
</html>

 

thanks all

Link to comment
https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/
Share on other sites

Refuses? Any errors?

 

Try echoing out variables, or die() the variables at certain stages to track things. Usually problems like this can be solved by taking some basic error tracking steps to try and trace it. Just work through your script to find out where it isn't working.

this line won't work

 

$mail = mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">");

 

you have it sending the email to

mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">");

 

and why are you putting it in a variable anyway?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.