By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

changing password script not running, help me?

P: 20
I have developed a login system but its failing to allow the user to change password.
Here is my code.
[PHP]
<?
require_once("system_fns.php");
session_start();
do_html_header("Changing password");
check_valid_user();
$new_passwd=($HTTP_POST_VARS['new_passwd']);
$new_passwd2=($HTTP_POST_VARS['new_passwd2']);
if (!filled_out($HTTP_POST_VARS))
{
echo "You have not filled out the form completely.
Please try again.";
display_user_menu();
exit;
}
else
{
if ($new_passwd!=$new_passwd2)
echo "Passwords entered were not the same. Not changed.";
else if (strlen($new_passwd)>16 || strlen($new_passwd)<6)
echo "New password must be between 6 and 16 characters. Try again.";
else
{
// attempt update
if (change_password($valid_user, $old_passwd, $new_passwd))
echo "Password changed.";
else
echo "Password could not be changed.";
}


}
display_user_menu();
?>
[/PHP]

These are the error messages I'm getting.

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
These are lines in question.
[PHP]
$new_passwd=($HTTP_POST_VARS['new_passwd']);
$new_passwd2=($HTTP_POST_VARS['new_passwd2']);
[/PHP]
Please help me.
Feb 15 '07 #1
Share this Question
Share on Google+
4 Replies


P: 99
what is the html code of the form?
Feb 15 '07 #2

Motoma
Expert 2.5K+
P: 3,235
What version of PHP are you using? Have you tried referencing them via $_POST rather than $HTTP_POST_VARS?
Feb 16 '07 #3

P: 20
what is the html code of the form?
Here is the html code

[HTML]
<form method='post' action='change_passwd.php'>
<table bgcolor=''>
<tr>
<td>Username:</td>
<td><input type='text' name='username' size=16 maxlength=16></td></tr>
<tr>
<td>Old Password:</td>
<td><input type='password' name='passwd'
size=16 maxlength=16></td></tr>
<tr>
<td>New Password <br />(between 6 and 16 chars):</td>
<td valign='top'><input type='password' name='new_passwd'
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type='password' name='new_passwd2' size=16 maxlength=16></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Change'></td></tr>
</table></form>
[/HTML]
Feb 16 '07 #4

P: 20
What version of PHP are you using? Have you tried referencing them via $_POST rather than $HTTP_POST_VARS?
I'm using PHP 4.4.4 version.Well I'm going to replace $HTTP_POST_VARS by
$_POST.
Thanks I hope its gonna work.
Feb 16 '07 #5

Post your reply

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