title: Update query using $_POST values
body: <p>I am trying to show user information using a small PHP script, called myinfo.php. The relevant part of which is shown below:</p>
  
  <pre><code>    while($return = mysql_fetch_assoc($result)) {
      echo "&lt;form action=UpdateInfo.php method=post&gt;";
      echo "&lt;p id=greeting&gt; Hi ".$return['FirstName'].", below is all of your personal information: &lt;/p&gt;";
      echo '&lt;p&gt; First Name: &lt;input type="text" name="firstname" value= "'.$return['FirstName'].'"/&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Surname: &lt;input type="text" name="surname" value= "'.$return['Surname'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; House Number: &lt;input type="number" name="housenumber" value= "'.$return['HouseNumber'].'"/&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Address Line One: &lt;input type=text name="addressone" value= "'.$return['AddressLineOne'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Address Line Two: &lt;input type=text name="addresstwo" value= "'.$return['AddressLineTwo'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; County: &lt;input type=text name="county" value= "'.$return['County'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Phone Number: &lt;input type=number name="phonenumber" value= "' .$return['PhoneNumber'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Email: &lt;input type=email name="email" value= "'.$return['Email'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Username: &lt;input type=text name="username" value= "'.$return['Username'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; Password: &lt;input type=password name="password" value= "'.$return['Password'].'" /&gt;&lt;/p&gt;';
      echo '&lt;p&gt; User Type: &lt;input type="text" name="usertype" value= "'.$return['UserType'].'" /&gt;&lt;/p&gt;';
      echo '&lt;input id="submit" type="submit" value="Update Info" /&gt;';
      echo "&lt;/form&gt;";
  } 
  </code></pre>
  
  <p>The input values are all pre filled with the users own information so the user can edit the input values and then click on the "update info" submit button in order to update his/her info. Once this button is clicked the user is sent to the "updateinfo.php" page where they have to confirm the change in information and are shown the changes they are about to make, as shown below:</p>
  
  <pre><code>    echo '&lt;p id="confirmation"&gt;Are you sure you wish to make the following changes to your personal information?&lt;/p&gt;';
      echo '&lt;form action="CompleteUpdate.php" method="post"&gt;';   
      echo "&lt;p&gt;First Name: " . $_POST["firstname"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Surname: " . $_POST["surname"] . "&lt;/p&gt;";
      echo "&lt;p&gt;House Number: " . $_POST["housenumber"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Address Line One: " . $_POST["addressone"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Address Line Two: " . $_POST["addresstwo"] . "&lt;/p&gt;";
      echo "&lt;p&gt;County: " . $_POST["county"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Phone Number: " . $_POST["phonenumber"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Email: " . $_POST["email"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Username: " . $_POST["username"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Password: " . $_POST["password"] . "&lt;/p&gt;";
      echo "&lt;p&gt;Usertype: " . $_POST["usertype"] . "&lt;/p&gt;";
      echo '&lt;input id="submit" type="submit" value="Update Info" /&gt;&lt;/form&gt;';
      echo '&lt;form action="CancelUpdate.php"&gt;&lt;input id="submit" type="submit" value="Cancel" /&gt;&lt;/form&gt;';
  </code></pre>
  
  <p>Here the user now clicks the "update info" button or decides to cancel the update. If the update info button is clicked the following PHP script is invoked:</p>
  
  <pre><code>    $sql=("UPDATE completeinfo SET FirstName='$_POST[firstname]', Surname='$_POST[surname]', AddressLineOne='$_POST[addresslineone]', AddressLineTwo='$_POST[addresslinetwo]', County='$_POST[county]', Email='$_POST[email]', Username='$_POST[username]', Password=SHA1('$_POST[password]'), UserType='$_POST[usertype]' WHERE Username='".$_SESSION['username']."'");
  </code></pre>
  
  <p>The problem I am having is that the update query instead of replacing the old values with the new ones, represented by the $_POST values, it now leaves them completely blank. The query knows exactly where to edit in my database so I must presume the "where" clause is working but for some reason $_POST is not fetching the correct values in the query, even though it works perfectly well in the previous PHP scripts. Any ideas how to solve this problem would be greatly appreciated. Thanks</p>