php - "Notice: Undefined variable" -


i'm getting error when run 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 * staff 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' username='$user_name'");     }     if ($insert) {         echo "password changed";     } else {         echo "password  not changed";     } } mysql_close($con); ?> 

well, because might not in if statement $insert gets set. if case $insert not exist en notice.

try check if variable exists like:

if (isset($insert)) {     echo "password changed"; } else {     echo "password  not changed"; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -