View Single Post
Old 10-05-2012, 07:05 PM   PM User | #43
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Sorry I should have posted that initially...

Here is the email which is sent to the user when they request to reset:
PHP Code:
//if this executes, database was updated with reset code. write email...
              
$to $email;
              
$subject "Demo-Central Reset Password."."\r\n";
              
$message "Hello ".$user."<br />\r\n";
              
$message .= "You have received this email because you have forgotten your password."."<br />\r\n";
              
$message .= "We have attached a link within the email which needs to be clicked in order to process"."<br />\r\n";
              
$message .= "your password reset. On this page you will be asked to enter your new password. Once you have done this"."<br />\r\n";
              
$message .= "you will then be able to login with your existing username and new password."."<br /><br />\r\n";
              
$message .= "<a href='htttp://www.labtec.0fees.net/DemorecSite/enter_new_pass.php?id={$id}&unique={$unique_id}'>Reset your password!</a><br /><br />";
              
$message .= "Kind regards,"."<br />\r\n";
              
$message .= "Demo-Central Administrator."."<br />\r\n";
              
              
$headers = array();
              
$headers[] = "MIME-Version: 1.0";
              
$headers[] = "Content-type: text/html; charset=iso-8859-1";
              
$headers[] = "From: Demo-Central Admin <admin@demo-central.com>";
              
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
              
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
              
$headers[] = "Subject: {$message}";
              
$headers[] = "X-Mailer: PHP/".phpversion();
      
              if(
mail($to,$subject,$messageimplode("\r\n",$headers))){
                 echo 
"You will be emailed shortly with further instructions on resetting your password.<br />";
                 echo 
"Please follow the <a href='index.php'>link</a> to the homepage.";
                 exit(
0);
              }
              else{
                 echo 
"There was an error sending your reset email.<br />";
                 echo 
"Please contact the site administrator at flipmodeskwaud@hotmail.co.uk to report the problem.<br />";
                 echo 
"Follow the link to the <a href='index.php'>homepage</a>.";
                 exit(
0);
              } 
As you can see there is a link which hold two values, here is the source code for that page, enter_new_pass.php:
PHP Code:
<?php

global $id;
global 
$uniq;

$id $_GET['id'];
$uniq $_GET['unique'];

echo 
$id."<br />";
echo 
$uniq;

?>
<!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>
   <title>Demo-Central New Password</title>
   <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
   <script type="text/javascript" src="javascripts/advert.js"></script>
   <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
   <link rel="stylesheet" type="text/css" href="css/fontface.css" />
   <link rel="stylesheet" type="text/css" href="css/menu.css" />
   <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
</head>
<body onload="window_onload()">

<div id="head">
   <img src="images/demo_banner_5_1.png" alt="DC Logo" title="Demo-Central" id="logo" border="0" />
   <?php if(!isset($_SESSION['username'])){?>
   <a href="login.php">Login</a>
   <a href="register.php">Register</a>
   <a href="reset_password.php">Reset Password</a>
   <?php } else{ ?>
   <a href="logout.php">Logout</a>
   <?php ?>
</div>

<div id="menu_div">
    <div id='cssmenu'>
        <ul>
            <li class='active '><a href='index.php'><span>Home</span></a></li>
            <li class='has-sub '><a href='#'><span>Games</span></a>
        <ul>
            <li><a href='gamelist.php'><span>Game List</span></a></li>
            <li><a href='files.php'><span>Files</span></a></li>
        </ul>
            </li>
            <li><a href='members.php'><span>Members</span></a></li>
            <li><a href=''><span>Forums</span></a></li>
            <li><a href='contact.php'><span>Contact</span></a></li>
            <li><a href='challenges.php'><span>Challenges !</span></a></li>
            <?php if(isset($_SESSION['username'])){ 
                     echo 
"<li><a href='membersarea.php'>Members Area</a></li>";
                  } 
            
?>
        </ul>
    </div>
    
    <form action="search.php" method="post" name="search_form">
       <input type="text" name="search" size="20" maxlength="60" />
       <input type="submit" name="submit" value="Search" />
    </form>
</div>

<div id="page_src_div">
<?php
$crumbs 
explode("/",$_SERVER["REQUEST_URI"]);
foreach(
$crumbs as $crumb){
    echo 
"<strong>";
    echo 
ucfirst(str_replace(array(".php","_"),array(""," "),$crumb) . ' &gt; ');
    echo 
"</strong>";
}
?>
</div>

<div id="content">

   <p id="welcome">Welcome to the <span class="red">Demo-Central</span> new password page.</p>
   <hr id="welcome_hr" noshade="noshade" />

   <form action="do_new_pass.php" method="post">
      <fieldset>
         <legend>Enter New Password</legend>
         <p><label for="password">New Password:</label><input type="password" name="password" id="password" /></p>
         <p><input type="submit" name="submit" value="Change Password" /><input type="reset" name="reset" value="Clear" /></p>
      </fieldset>
   </form>

</div>

<div id="footer">

<h3 id="useful_link_header">Useful Links:</h3>
<h3 id="internal_link_header">Internal Links:</h3>

<ul id="first_ul">
   <li><a href="http://www.gamebanana.com" target="_blank">GameBanana</a></li>
   <li><a href="http://www.cstrike-planet.com" target="_blank">CStrike-Planet</a></li>
   <li><a href="http://uk.gamespy.com/" target="_blank">GameSpy</a></li>
   <li><a href="http://store.steampowered.com/" target="_blank">Steam</a></li>
   <li><a href="http://tpuc.org/" target="_blank">TPUC.org</a></li>
</ul>

<ul id="second_ul">
   <li><a href="http://www.chess.com/" target="_blank">Chess.com</a></li>
   <li><a href="http://download.deusexnetwork.com/" target="_blank">Deus Ex File Archive</a></li>
   <li><a href="http://www.teamspeak.co.uk/" target="_blank">Teamspeak</a></li>
   <li><a href="http://www.mirc.com/" target="_blank">mIRC</a></li>
   <li><a href="http://www.wampserver.com/en/" target="_blank">WAMP</a></li>
</ul>

<ul id="third_ul">
   <li><a href="index.php">Home</a></li>
   <li><a href="files.php">Files</a></li>
   <li><a href="members.php">Members</a></li>
   <li><a href="challenges.php">Challenges!</a></li>
   <li><a href="contact.php">Contact Us</a></li>
</ul>

<div id="adverts">
   <a href="http://z3.invisionfree.com/HunterKillerz/index.php?act=idx" name="advertLink" target="_blank">
      <img src="images/AdvertImage1.jpg" alt="adverts" name="imgAdvert" class="adverts" border="0" />
   </a>
</div>

<p>2012 &copy; Demo-Central.com<br />
   Site design by<br /><span>Thomas S.P</span></p>

</div>
</body>
</html>
As you can see I retrieve the values and at this point, they echo out fine. The form on this page goes into a file called do_new_pass.php, which is here:
PHP Code:
<?php

echo $id."<br />";
echo 
$uniq;

$con = new mysqli("localhost","root","","demo_central");

$stmt $con->prepare("SELECT * FROM members WHERE id=? AND reset=?");
$stmt->bind_param("is",$id,$uniq);
$stmt->bind_result($id,$user,$pass,$email,$join_date,$hash,$reset);
$stmt->execute();
$stmt->store_result();
$stmt->fetch();
echo 
$user;

?>
The statement isn't returning a value. No num_rows or affected_rows values apart from 0.

It is clearly something to do with those global variables because they do not echo out in this action script. Is there a way I can get them there?

Regards,

LC.
LearningCoder is offline   Reply With Quote