473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

password reset function is not working

1
Guys,
I am trying to get this password reset functionality wor for me but I am not successful at all. Please somebody help me. I get "Your password could not be reset - please try again later" so I think the get_random_word function is not working right. Here are the scripts:

This is the script after the user enters his/her userid.

<?php
require_once("bookmark_fns.php");

// creating short variable name
$username = $_POST['username'];

try
{
$password = reset_password($username); //I think this is not working
notify_password($username, $password);
echo 'Your new password has been emailed to you.<br />';
}
catch (Exception $e)
{
echo 'Your password could not be reset - please try again later.';
}

?>

This is the reset_password function:

// set password for username to a random value
// return the new password or false on failure
{
// get a random dictionary word b/w 6 and 13 chars in length
$new_password = get_random_word(6, 13);

if($new_password==false)
throw new Exception('Could not generate new password.');
// add a number between 0 and 999 to it
// to make it a slightly better password
srand ((double) microtime() * 1000000);
$rand_number = rand(0, 999);
$new_password .= $rand_number;
// set user's password to this in database or return false
$conn = db_connect();
$result = $conn->query( "update user
set passwd = sha1('$new_password')
where username = '$username'");
if (!$result)
throw new Exception('Could not change password.'); // not changed
else
return $new_password; // changed successfully
}

This is get_randow_word function: I think this can be the problem as well:

function get_random_word($min_length, $max_length)
// grab a random word from dictionary between the two lengths
// and return it
{
// generate a random word
$word = '';
// remember to change this path to suit your system
$dictionary = '/usr/dict/words';
$fp = @fopen($dictionary, 'r');
if(!$fp)
return false;
$size = filesize($dictionary);

// go to a random location in dictionary
srand ((double) microtime() * 1000000);
$rand_location = rand(0, $size);
fseek($fp, $rand_location);

// get the next whole word of the right length in the file
while (strlen($word)< $min_length || strlen($word)>$max_length || strstr($word, "'"))
{
if (feof($fp))
fseek($fp, 0); // if at end, go to start
$word = fgets($fp, 80); // skip first word as it could be partial
$word = fgets($fp, 80); // the potential password
};
$word=trim($word); // trim the trailing \n from fgets
return $word;
}


I am not sure maybe my ISPELL dictionary is not working, maybe I am not putting this in the correct directory when I upload it to the hosting server but it is not working. Please help me out here. Thank you.
Jan 27 '06 #1
0 2322

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Robert Kattke | last post by:
Subject: Can you retrieve/restore a MySQL user Password ? I'm working on my own, local WXP, MySQL, version: 3.23.38-nt and I have the "root" password, and normally use the root account. I have...
2
by: Rod | last post by:
I have a requirement in which I need to allow the user to log into our ASP.NET application, but also be able to change their Windows password, if it is expired. I had thought that Windows...
1
by: NancyASAP | last post by:
Thought I'd share this since it took me a long time to get it working. Thanks to a bunch of contributers in Google Groups who shared javascript, etc. The question was: How can I put a reset...
0
by: damontimm | last post by:
My setup: Mac OS 10.4.4; mysql 4.x ... everything was installed and working fine for some time. Today, I added drupal to my system and had to create a new database in mysql -- now I am having some...
6
by: jarice1978 | last post by:
Hello, I have been scanning the internet for a few days now. That is not working. So now it is time to post! I have read a few other posts on here about authentication but they do not match...
4
by: custommx3 | last post by:
I have designed a site that requires users to login. Me being new to php, I hired a guy to help me setup the database. He set it up and it works flawlessly. Well.. instead of helping me finish the...
2
by: chaos | last post by:
Hi all, i need help in this forgot password page, as the error message is show in another page cause the arrangement of the design in a mess. As i want to show the error message on the forgot...
2
by: DarthPeePee | last post by:
Hello everyone. I am working on a Password Strength Meter and I am running into 1 problem that I would like to fix. When pressing the "Clear Password & Try Again" button, the password clears...
15
by: ejstefl | last post by:
Hello, I have a situation where I have to share user names and passwords for a list of sites among several (30 or so) users. These passwords must be reset every 90 days and anytime any one of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.