change password
<p>I've created a code to change a password. Now it seem contain an error. 
When I fill in the form to change password, and click save the error message:</p>

<blockquote>
  <p>You forgot enter your userid!</p>
  
  <p>Please try again.</p>
</blockquote>

<p>I really don’t know what the error message means.  Please guys. Help me fix it.</p>

<p>Here's is the code:</p>

<pre><code>&lt;?php # change password.php

//set the page title and include the html header.
$page_title = 'Change Your Password';
//include('templates/header.inc');

if(isset($_POST['submit'])){//handle the form
 require_once('connectioncomplaint.php');//connect to the db.
 //include "connectioncomplaint.php";

 //create a function for escaping the data.
 function escape_data($data){
  global $dbc;//need the connection.
  if(ini_get('magic_quotes_gpc')){
   $data=stripslashes($data);
  }
  return mysql_real_escape_string($data);
 }//end function

 $message=NULL;//create the empty new variable.

 //check for a username
 if(empty($_POST['userid'])){
  $u=FALSE;
  $message .='&lt;p&gt; You forgot enter your userid!&lt;/p&gt;';
 }else{
  $u=escape_data($_POST['userid']);
 }

 //check for existing password
 if(empty($_POST['password'])){
  $p=FALSE;
  $message .='&lt;p&gt;You forgot to enter your existing password!&lt;/p&gt;';
 }else{
  $p=escape_data($_POST['password']);
 }

 //check for a password and match againts the comfirmed password.
 if(empty($_POST['password1'])) {
  $np=FALSE;
  $message .='&lt;p&gt; you forgot to enter your new password!&lt;/p&gt;';
 }else{
  if($_POST['password1'] == $_POST['password2']){
  $np=escape_data($_POST['password1']);
 }else{
  $np=FALSE;
  $message .='&lt;p&gt; your new password did not match the confirmed new password!&lt;/p&gt;';
 }
}

if($u &amp;&amp; $p &amp;&amp; $np){//if everything's ok.

 $query="SELECT userid FROM access WHERE (userid='$u' AND password=PASSWORD('$p'))";
 $result=@mysql_query($query);
 $num=mysql_num_rows($result);
 if($num == 1){
  $row=mysql_fetch_array($result, MYSQL_NUM);

  //make the query
  $query="UPDATE access SET password=PASSWORD('$np') WHERE userid=$row[0]";
  $result=@mysql_query($query);//run the query.
  if(mysql_affected_rows() == 1) {//if it run ok.

   //send an email,if desired.
   echo '&lt;p&gt;&lt;b&gt;your password has been changed.&lt;/b&gt;&lt;/p&gt;';
   //include('templates/footer.inc');//include the HTML footer.
   exit();//quit the script.

  }else{//if it did not run OK.
   $message= '&lt;p&gt;Your password could not be change due to a system error.We apolpgize for any inconvenience.&lt;/p&gt;&lt;p&gt;' .mysql_error() .'&lt;/p&gt;';
   }
  }else{
   $message= '&lt;p&gt; Your username and password do not match our records.&lt;/p&gt;';
  }
  mysql_close();//close the database connection.

 }else{
  $message .='&lt;p&gt;Please try again.&lt;/p&gt;';
 }
}//end of the submit conditional.

//print the error message if there is one.
if(isset($message)){
 echo'&lt;font color="red"&gt;' , $message, '&lt;/font&gt;';
}
?&gt;

&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
</code></pre>
