No errors any more. I use this now:
PHP Code:
<FORM method="post" action="<? echo $PHP_SELF;?>">
<table>
<tr>
<td>
<p>Accountname:
</td>
<td>
<input name="name" type="textfield" />
</td>
</tr>
<tr>
<td>
<p>Current Password:
</td>
<td>
<input name="Cpass" type="textfield" />
</td>
</tr>
</tr>
<tr>
<td>
<p>New Password:
</td>
<td>
<input name="Npass" type="textfield" />
</td>
</tr>
<tr>
<td>
<input type="submit" value="change" name="change" />
</td>
</tr>
</form>
<?php
include('config.php');
$name = anti_injection($_POST ["name"]);
$Cpass = anti_injection($_POST ["Cpass"]);
$Npass = anti_injection($_POST ["Npass"]);
if(isset($_POST['change']))
{
odbc_exec ($connect, "SELECT * FROM login WHERE UserID='".$name."'");
if($Cpass==$row['Password'])
{
odbc_exec ("UPDATE login SET Password='".$Npass."' WHERE Password='".$Cpass."'");
echo"Changed Succesfully!";
}
else
{
echo"Wrong Password";
}
}
?>
But it script always says Wrong password if it is uncorrect or correct.
And if i do this:
PHP Code:
ini_set('display_errors', 1);
error_reporting(E_ALL);
I get this:
Code:
Notice: Undefined index: name in C:\xampp\htdocs\passchange\change.php on line 40
Notice: Undefined index: Cpass in C:\xampp\htdocs\passchange\change.php on line 41
Notice: Undefined index: Npass in C:\xampp\htdocs\passchange\change.php on line 42
That are this lines:
$name = anti_injection($_POST ["name"]);
$Cpass = anti_injection($_POST ["Cpass"]);
$Npass = anti_injection($_POST ["Npass"]);
The action anti_injection is in the config.php.
PHP Code:
function anti_injection($sql)
{
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}
?>