I don't know how much help this is going to be but i'm going to toss out a suggestion or two in a moment.
Firstly, I need to add that I just got up after a night of being heavily intoxicated and my brain isn't cooperating with me 😕
Are the $username and $oldpw variables made up names specifically for your check_current_pw() function?
If not, you may need to make them global to the function by declaring them as such.
<?php
function check_current_pw( $username,$oldpw )
{
global $table;
global $username;
global $oldpw;
$result = mysql_query( "SELECT username,pw FROM $table WHERE username = '$username' AND pw = '$oldpw'" );
if( mysql_num_rows( $result ) != 1 )
{
return false;
}
else {
return true;
}
}
?>
Couple of examples
<?php
### Variable Scope: Variables defined outside functions are not accessible from within a function by default.
$life = "Even at the worst of times, life is still pretty great.";
function meaningOfLife()
{
echo "The meaning of life is: $life";
}
### Now let's call the function
meaningOfLife();
### prints The meaning of life is:
/*
* Notes
*
The value of the variable $life is not printed.
This is because the meaningOfLife() function has
no access to the global $life variable; $life is
empty when the function attempts to print it.
On the whole, this is a good thing. We're saved
from potential clashes between identically named
variables, and a function can always demand an
argument if it needs information from the outside world.
*
*
*/
?>
<?php
$life = "Even at the worst of times, life is still pretty great.";
function meaningOfLife()
{
global $life; ### note the global keyword here.
echo "The meaning of life is: $life";
}
### Now let's call the function
meaningOfLife();
### prints The meaning of life is: Even at the worst of times, life is still pretty great.
/*
* Notes
*
The function now refers to the global $life variable that
was declared outside of the function, and therefore is printed.
You'll need to use the global statement for every function
that wishes to access a particular global variable.
Caution is required while doing this, however.
If we manipulate the contents of the variable within the function,
$life will be changed for the script as a whole - possibly resulting in
unexpected behaviour.
*
*
*/
?>
I hope this helps you out and if not, sorry .. my intentions were only to help :quiet: