473,782 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my script not running

20 New Member
i have two scripts that are not running to reset a password that has been forgotten and the other to change old password.

here are the scripts.

change_passwd.p hp

<?
require_once("s ystem_fns.php") ;
session_start() ;
do_html_header( "Changing password");
//check_valid_use r();
$new_passwd=($_ POST['new_passwd']);
$new_passwd2=($ _POST['new_passwd2']);
if (!filled_out($H TTP_POST_VARS))
{
echo "You have not filled out the form completely.
Please try again.";
display_user_me nu();
//do_html_footer( );
exit;
}
else
{
if ($new_passwd!=$ new_passwd2)
echo "Passwords entered were not the same. Not changed.";
else if (strlen($new_pa sswd)>16 || strlen($new_pas swd)<6)
echo "New password must be between 6 and 16 characters. Try again.";
else
{
// attempt update
if (change_passwor d($valid_user, $old_passwd, $new_passwd))
echo "Password changed.";
else
echo "Password could not be changed.";
}


}
display_user_me nu();
//do_html_footer( );
?>

error warnings from this code are.

Notice: Undefined index: new_passwd in C:\project\test \change_passwd. php on line 6

Notice: Undefined index: new_passwd2 in C:\project\test \change_passwd. php on line 7
New password must be between 6 and 16 characters. Try again.
Fatal error: Call to undefined function: display_user_me nu() in C:\project\test \change_passwd. php on line 33


function change_password ($username, $old_passwd, $new_passwd)
// change password for username/old_password to new_password
// return true or false
{
// if the old password is right
// change their password to new_password and return true
// else return false
if (login($usernam e, $old_passwd))
{
if (!($conn = db_connect()))
return false;
$result = mysql_query( "update users
set passwd = password('$new_ passwd')
where username = '$username'");
if (!$result)
return false; // not changed
else
return true; // changed successfully
}
else
return false; // old password was wrong
}

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 = "";
$dictionary = "/usr/share/dict/words"; // the ispell dictionary
$fp = fopen($dictiona ry, "r");
$size = filesize($dicti onary);

// 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)
{
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($wor d); // trim the trailing \n from fgets
return $word;
}
function reset_password( $username)
// 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_passwd = get_random_word (6, 13);

// 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_passwd .= $rand_number;

// set user's password to this in database or return false
if (!($conn = db_connect()))
return false;
$result = mysql_query( "update users
set passwd = password('$new_ password')
where username = '$username'");
if (!$result)
return false; // not changed
else
return $new_passwd; // changed successfully
}

function notify_password ($username, $passwd)
// notify the user that their password has been changed
{
if (!($conn = db_connect()))
return false;
$result = mysql_query("se lect email from users
where username='$user name'");
if (!$result)
return false; // not changed
else if (mysql_num_rows ($result)==0)
return false; // username not in db
else
{
$email = mysql_result($r esult, 0, "email");
$from = "From: support@learnin g_system \r\n";
$mesg = "Your password has been changed to $password \r\n"
."Please change it next time you log in. \r\n";
if (mail($email, "Learning System login information", $mesg, $from))
return true;
else
return false;
}
}
?>


these are the errror warnings i got.

Warning: fopen(/usr/share/dict/words) [function.fopen]: failed to open stream: No such file or directory in C:\project\test \user_auth_fns. php on line 99

Warning: filesize() [function.filesi ze]: Stat failed for /usr/share/dict/words (errno=2 - No such file or directory) in C:\project\test \user_auth_fns. php on line 100

Warning: fseek(): supplied argument is not a valid stream resource in C:\project\test \user_auth_fns. php on line 105

Warning: feof(): supplied argument is not a valid stream resource in C:\project\test \user_auth_fns. php on line 110

Warning: fgets(): supplied argument is not a valid stream resource in C:\project\test \user_auth_fns. php on line 112

Warning: fgets(): supplied argument is not a valid stream resource in C:\project\test \user_auth_fns. php on line 113

------------------------------------------------------------------------------------------------------------------

yo help is greatly appreciated.
Feb 14 '07 #1
1 1402
ronverdonk
4,258 Recognized Expert Specialist
Please read the Posting Guidelines before you post in this forum!.
Especially the part about enclosing posted code within code or php tags!

moderator
Feb 14 '07 #2

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

Similar topics

4
2887
by: Damien Renwick | last post by:
I have a php script which simply stops midway through a while loop that processes records returned by a MySQL query. The HTML page continues trying to load the page but the php has stopped running and eventually I get a timeout. The script is running in my development environment which consists of php 4.3.4, Apache 1.3.28 and MySQL 4.0.17, installed on Windows XP with Service Pack 2. I suspect that there may be a problem with my...
10
6194
by: Larry Neylon | last post by:
Hi All, I want to perform the simple task of running an ASP script as a scheduled job. Previously I've always either run a .vbs script via windows Scheduler, or put some logic in my global.asa, both of which have worked fine. Unfortunately there are technical reasons (too complicated to go into here) which mean I can't use either the global.asa or a standalone vbs script for
5
3484
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() - after sending, a small summary html page is sent to the user with number sent, time taken and a simple navigation choice. Up to about 100 emails it all works fine - this takes the server about 27 secs . Any more than that and although the emails are...
9
1914
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running in. Thanks Scotty
1
47487
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.