View Single Post
Old 10-05-2012, 09:42 PM   PM User | #45
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 860
Thanks: 68
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
Ah I did remember sessions and knew they held values between pages but didn't want to use them.

Here is my code:
PHP Code:

<?php
session_start
();

$id $_SESSION['id'];
$uniq $_SESSION['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();
$a_rows $stmt->affected_rows;

if(
$a_rows == 1){
   
$stmt->fetch();//fetch all of the users data from their row...
   
   
$new_pass mysqli_real_escape_string($con,$_POST['password']);
   
   
$hashed sha1($hash.$new_pass.$hash);
   
   
$stmt $con->prepare("UPDATE members SET password=? WHERE reset=?");
   
$stmt->bind_param("ss",$hashed,$uniq);
   
$stmt->execute();
   
$stmt->store_result();
   
$a_rows $stmt->affected_rows;
   
   if(
$a_rows == 1){
      
$null NULL;
      
$con mysqli_query("UPDATE members SET reset='{$null}' WHERE reset='{$reset}'");
   
      print(
"You have successfully changed your password.");
      print(
"Please return to the <a href='login.php'>login</a> page.");
      exit(
0);
   }
   else{
      print(
"There was an error changing your password.");
      exit(
0);
   }
   
   
}
else{
   print(
"Error with the query. No match found for resetting.<br />");
   print(
"Please contact the site administrator at flipmodeskwaud@hotmail.co.uk to report the problem.<br />");
   print(
"Please click the link to return to the <a href='reset_password.php'>homepage</a>.");
   exit(
0);
}


?>
I am wondering, how do I set the reset column value back to NULL? As you can see I tried creating a variable and using that but it just 'empties' the reset column. It's not NULL as such, but it has no value.

Do you know how I can get that row's reset column back to the initial NULL value?

Regards,

LC.
__________________
Carewizard - http://www.carewizard.co.uk
LearningCoder is offline   Reply With Quote