I'm getting this error when I run the following change password script:
Notice: Undefined variable: $insert in C:\xampp\htdocs\oh\change.php on line 21 Password not changed
<?php
include('db_connection.php');
include('crypt.php');
session_start();
if (isset($_POST['submit'])) {
$oldpassword = $_POST['current_password'];
$newpassword= $_POST['new_password'];
$confirm_password =$_POST['confirm_password'];
$user_name = $_SESSION['UserName'];
$old = decrypt($oldpassword);
$select = mysql_query("SELECT * FROM staff WHERE UserName='$user_name'");
$fetch = mysql_fetch_array($select);
$data_password = $fetch['password';
if ($newpassword == $confirm_password && $data_password == $old) {
$pass = encrypt($confirm_password);
$insert = mysql_query("UPDATE staff SET password='$pass' WHERE UserName='$user_name'");
}
if ($insert) {
echo "Password changed";
} else {
echo "Password not changed";
}
}
mysql_close($con);
?>