error message on change password code using php -


i used script user change password when logged in , when tested showed error message

notice: undefined index: username in /home/www/sitename/directory/changepw.php on line 8 notice: undefined index: pin in /home/www/sitename/directory/changepw.php on line 9 notice: undefined index: newpassword in /home/www/sitename/directory/changepw.php on line 10 notice: undefined index: repeatnewpassword in /home/www/sitename/directory/changepw.php on line 11

this have in line 8,9,10and 11

 $username = $_post['username'];   $pin = $_post['pin'];   $newpassword = $_post['newpassword'];   $repeatnewpassword = $_post['repeatnewpassword']; 

this html code below

<style type="text/css">     a:link {        text-decoration: none;     }     a:visited {         text-decoration: none;     }     a:hover {         text-decoration: none;     }     a:active {         text-decoration: none;     } </style> <div id="inlogscherm"> <form name="form1" method="post" action="changepw.php">     <div class="textm">change password</div><br>     <div class="text">username:</div><div class="invulbalkje"><? echo    "{$_session['username']}"; ?></div><br />     <input name="username" type="text" id="username" value="<? echo   "{$_session['username']}"; ?>">   <div class="text">password:</div><input name="pin" type="password"  id="pin" class="invulbalkje"><br />     <div class="text">new password:</div><input name="newpassword" type="password" id="newpassword" class="invulbalkje"><br />     <div class="text">repeat new password:</div><input name="repeatnewpassword" type="password" id="repeatnewpassword" class="invulbalkje"><br />     <input type="submit" name="submit" value="change" class="button">   <a href="logout.php">logout</a> </form> 

this php code below

<?php      error_reporting(e_all);     ini_set('display_errors', 1);     session_start();     include 'db.php';       $username = $_post['username'];     $pin = $_post['pin'];     $newpassword = $_post['newpassword'];     $repeatnewpassword = $_post['repeatnewpassword'];      $encrypted_password=md5($pin);     $encrypted_newpassword=md5($newpassword);     $wtbusers = '`wtbusers`';//this should defined (change whatever table name)      $result = mysql_query("select pin $wtbusers     username='$username' , pin = '$pin'");     if(!$result)      {          echo"<script>alert('please fill form correctly')</script>"; }          if(mysql_num_rows($result) != 0){             if($newpassword == $repeatnewpassword){             $sql=mysql_query("update $wtbusers set pin='$pin'  username='$username'");                     if($sql)              {                  echo"<script>alert('successful')</script>";             }             else             {                  echo"<script>alert('error')</script>";             }                } else {            echo"<script>alert('error_password_not_matched')</script>";     } } else {      echo"<script>alert('please fill form correctly')</script>"; }  ?>  

thank you.

all other problems aside , addressing actual question; there no checking see if post being made can tell, adding @ symbol those, $username = @$_post['username']; in context fastest fix rid of them recommend checking post first. isset pretty that.

alternatively can turn off error reporting notices doing

error_reporting(e_all & ~e_notice); 

see error_reporting


Comments