Sorry, there\'s been a problem resetting your password. Please contact the site administrator for assistance.
'; include 'footer.php'; exit; } else { $row = mysqli_fetch_array($gettemppass); $cont_temppass = $row['cont_temppass']; $cont_temppass2 = md5(trim($cont_temppass)); echo ''.$cont_temppass.'
'; // update the db $updatepassquery = " UPDATE contractors SET cont_pass = '$cont_temppass2' WHERE cont_username = '$cont_username' AND cont_temppass = '$cont_temppass' LIMIT 1 "; $updatepass = mysqli_query($dbc, $updatepassquery) or trigger_error("Bad updatepass: " . mysqli_error($dbc)); if (!$updatepass) { include 'technical.php'; include 'footer.php'; exit; } echo "Your password has been changed.
Your new password is $cont_temppass
If you wish, you can log in now with your new password. After logging in, you may wish to edit your account settings and change your password to one that will be easier to remember.
"; // Give them a login form include 'loginform.php'; } } // END confirmation and resetting password // Make a temp password and send e-mail if ( isset($_POST['resetit']) && isset($_POST['cont_email']) ) { $cont_email = escape_data($_POST['cont_email']); // First make sure the e-mail address is in the db $getemailquery = " SELECT cont_email FROM contractors WHERE cont_email = '$cont_email' LIMIT 1 "; $getemail = mysqli_query($dbc, $getemailquery) or trigger_error('Bad getemail query: '.mysqli_error($dbc)); if (!$getemail) { include 'technical.php'; include 'footer.php'; exit; } elseif ( mysqli_num_rows($getemail) < 1) { echo 'Sorry, that e-mail address could not be found in our records. Please contact the site administrator for assistance.
'; include 'footer.php'; exit; } else { // found e-mail - now make a new random password and e-mail it $build_pass = ''; for ( $counter=1; $counter<=8; $counter++ ) { $random_number = rand(97,122); $build_pass .= chr($random_number); } // echo $build_pass; // now, insert the random pass into the db $addtempquery = " UPDATE contractors SET cont_temppass = '$build_pass' WHERE cont_email = '$cont_email' "; $addtemp = mysqli_query($dbc, $addtempquery) or trigger_error('Bad addtemp query: ' . mysqli_error($dbc)); if (!$addtemp) { include 'technical.php'; include 'footer.php'; exit; } // Now send an email to the contractor - get their name, company and username from db, then send e-mail $getcontquery = " SELECT cont_id, cont_contactname, cont_companyname, cont_username FROM contractors WHERE cont_email = '$cont_email' LIMIT 1 "; $getcont = mysqli_query($dbc, $getcontquery) or trigger_error('Bad getcont query: '.mysqli_error($dbc)); $row = mysqli_fetch_array($getcont); $cont_id = $row['cont_id']; $cont_contactname = $row['cont_contactname']; $cont_companyname = $row['cont_companyname']; $cont_username = $row['cont_username']; if (!$getcont) { include 'technical.php'; include 'footer.php'; exit; } $sendto = $cont_contactname.'<'.$_POST['cont_email'].'>'; $subj = 'Your '.$config['company'].' password has been reset'; $msg = 'Greetings from '.$config['company'].".\n\n"; $msg .= "You recently used our \"Forgot Password\" link to have your password reset. "; $msg .= "The username for your account is ".$cont_username. ".\n\n"; $msg .= "Please confirm this change to your account by following this link:\n"; $msg .= $config['url'] . "/resetpass.html?confirm=1&u=$cont_username&p=$build_pass\n\n"; $msg .= "If you do not open the above link in your browser, your password will not be reset.\n\n"; $msg .= "Thank you for your interest in {$config['company']}.\n\nSincerely,\n\n{$config['company']}\n\n"; $fromemail = 'webmaster@sewercontractors.com'; $headers = "From: {$config['company']} <{$config['main_email']}>\n"; $headers .= "X-Sender: {$config['company']} <{$config['main_email']}>\n"; $headers .= "Reply-To: {$config['company']} <{$config['main_email']}>\n"; $headers .= "Return-Path: <{$config['main_email']}>"; $extra = "-f{$config['main_email']}"; // echo 'You have been sent an e-mail with a temporary password for your account.
That e-mail will contain a link that you will need to open in your browser in order to log in and change your permanent password.
"; } else { echo "Sorry, there's been a problem resetting your password.
"; } } } // Display form to enter email address if ( !isset($_POST['resetit']) && !isset($_GET['confirm']) ) { echo 'A new password will be created and sent to the e-mail address we have on file for you.
If you no longer have access to that e-mail address, please contact the site administrator.
'; echo ''; } ?>