title: Database not being updated with 'Edit user form'
body: <p>I have an administrator page that allows admins to edit details of the users who have just registered. Everyone's 'access levels' are defaulted to 4 and it is up to the admin to change their access level to '2' for a tutor or '3' for a student. </p>
  
  <p><strong>adminpage.php</strong></p>
  
  <pre><code>    &lt;div class="container"&gt;
                      &lt;h3&gt; New Members &lt;/h3&gt;
  
                      &lt;?php
  
                      $query = "Select * FROM users WHERE accessLevel = '4'";
  
                      $result = mysqli_query($conn, $query);
                      if (mysqli_num_rows($result) &gt; 0) {
                          while ($row = mysqli_fetch_assoc($result)) {
                              $userID = $row['userID'];
                              $firstName = $row['firstName'];
                              $lastName = $row['lastName'];
                              $emailAddress = $row['emailAddress'];
                              $accessLevel = $row['accessLevel']; 
  
                              echo
                              "&lt;div class = 'row'&gt;
                              &lt;div class='col-sm-12 col-md-6 col-lg-3'&gt;
                              &lt;div class='box'&gt; 
                              &lt;h5&gt; User ID: $userID &lt;/h5&gt;
                              &lt;h5&gt; User Name: $firstName $lastName &lt;/h5&gt;
                              &lt;p&gt; Email: $emailAddress &lt;/p&gt;
                              &lt;p&gt; Access Level: $accessLevel&lt;/p&gt;
                              &lt;a href = 'editUser.php?getUser=$userID' name='Edit Details' class = 'button'&gt;Edit Details&lt;/a&gt;
                              &lt;/div&gt;
                              &lt;/div&gt;
  
  
  
                              &lt;/div&gt;";
                          }
                      }
  </code></pre>
  
  <p><strong>editUser.php</strong></p>
  
  <pre><code>    &lt;?php
      include ('connection.php');
      $getID = $_GET['getUser'];
      $query = "Select * From users where userID ='$getID'";
      $return = mysqli_query($conn, $query);
      ?&gt;
  
  
   &lt;?php
                  include ('connection.php');
                  $userQuery = "Select * FROM users WHERE userID = '$getID'";
                  $return = (mysqli_query($conn, $userQuery));
  
                  if (mysqli_num_rows($return) &gt; 0) {
                      while ($row = mysqli_fetch_assoc($return)) {
  
                          $userID = $row['userID'];
                          $firstName = $row['firstName'];
                          $lastName = $row['lastName'];
                          $emailAddress = $row['emailAddress'];
                          $password = $row['password'];
                          $accessLevel = $row['accessLevel'];
                      }
  
                      echo
                      "&lt;h5&gt; Edit Profile for $firstName $lastName &lt;/h5&gt;;
  
                      &lt;form class ='form' method ='POST' name ='Update' action= 'updatedProfile.php?getid=$getID'&gt;
                      &lt;fieldset&gt;
                      &lt;legend&gt;Update Profile Details&lt;/legend&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'userID'&gt;UserID&lt;/label&gt;
                      &lt;input type = 'number' value='$userID' id ='userID' placeholder = 'UserID'&gt;
                      &lt;/div&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'firstName'&gt;First Name&lt;/label&gt;
                      &lt;input type = 'text' value='$firstName' id = 'firstName' placeholder = 'FirstName'&gt;
                      &lt;/div&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'lastName'&gt;Last Name&lt;/label&gt;
                      &lt;input type = 'text' value = '$lastName' id='lastName' placeholder = 'Last Name'&gt;
                      &lt;/div&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'emailAddress'&gt;Email&lt;/label&gt;
                      &lt;input type = 'email' value='$emailAddress' id ='emailAddress' placeholder = 'emailAddress'&gt;
                      &lt;/div&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'emailAddress'&gt;Password&lt;/label&gt;
                      &lt;input type = 'password' value='$password' id ='password' placeholder = 'Password'&gt;
                      &lt;/div&gt;
                      &lt;div class = 'input-group fluid'&gt;
                      &lt;label for = 'emailAddress'&gt;Access Level&lt;/label&gt;
                      &lt;input type = 'number' value='$accessLevel' id ='accessLevel' placeholder = 'Access Level'&gt;
                      &lt;/div&gt;
                      &lt;button&gt;Update Details&lt;/button&gt;
  
                      &lt;/fieldset&gt;
                      &lt;/form&gt;         
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;";
                  }
                  ?&gt;
  
                  &lt;?php
                  include("connection.php");
  
  
                  if (isset($_POST['userID'])) {
                      $userID = $_POST['userID'];
                  } else {
                      $error = true;
                      echo "big error";
                  }
                  if (isset($_POST['emailAddress'])) {
                      $emailAddress = $_POST['emailAddress'];
                  } else {
                      $error = true;
                  }
                  if (isset($_POST['firstName'])) {
                      $firstName = $_POST['firstName'];
                  } else {
                      $error = true;
                  }
                  if (isset($_POST['lastName'])) {
                      $lastName = $_POST['lastName'];
                  } else {
                      $error = true;
                  }
  
                  if (isset($_POST['accessLevel'])) {
                      $accessLevel = $_POST['accessLevel'];
                  } else {
                      $error = true;
                  }
  
                  if (isset($_POST['password'])) {
                      $password = $_POST['password'];
                  } else {
                      $error = true;
                  }
  
                  if (!$error) {
                      //$update = "UPDATE `rdonaghy08`.`users` SET userID='$userID', `firstName` = '$firstName', `lastName` = '$lastName', `password` = '$password', `accessLevel` = '$accessLevel' WHERE `users`.`userID` = '$getID'";
                      $update = "UPDATE users SET userID='$userID', firstName = '$firstName', lastName = '$lastName', password = '$password', accessLevel = '$accessLevel' WHERE userID = '$getID'";
                      $return = mysqli_query($conn, $update) or die(mysqli_errno($conn));
                  }
  </code></pre>
  
  <p><strong>And finally, updatedProfile.php</strong> </p>
  
  <pre><code>&lt;?php
  include 'connection.php';
  $getid = $_GET['getid'];
  
  if (isset($_POST['userID'])) {
      $userID = $_POST['userID'];
  } else {
      $error = true;
  }
  if (isset($_POST['emailAddress'])) {
      $emailAddress = $_POST['emailAddress'];
  } else {
      $error = true;
  }
  if (isset($_POST['firstName'])) {
      $firstName = $_POST['firstName'];
  } else {
      $error = true;
  }
  if (isset($_POST['lastName'])) {
      $lastName = $_POST['lastName'];
  } else {
      $error = true;
  }
  
  if (isset($_POST['accessLevel'])) {
      $accessLevel = $_POST['accessLevel'];
  } else {
      $error = true;
  }
  
  if (isset($_POST['password'])) {
      $password = $_POST['password'];
  } else {
      $error = true;
  }
  
  
  if (!$error) {
      $update = "UPDATE users SET userID='$userID', 
      emailAddress='$emailAddress',firstName='$firstName', lastName='$lastName'accessLevel ='$accesslevel',password='$password' WHERE userID = '$getid'";
      $return = mysqli_query($conn, $update) or die(mysqli_errno($conn));
  } else {
      "something wrong";
  }
  
  
  
  $returnQuery = "SELECT * FROM users WHERE userID='$getid'";
  $return = mysqli_query($conn, $returnQuery);
  
  
  
  
  if (mysqli_num_rows($return) &gt; 0) {
      while ($row = mysqli_fetch_assoc($return)) {
          $userEmail = $row['emailAddress'];
          $userID = $row['userID'];
      }
  }
  
  
  $content = "
  
              Please use the following link to login in with your 
                          new details: 
              http://xxxxxxxxxxxxxxx@xxxxxxx.co.uk
  
                          Please make a note of your new User name, 
                          you will need this to log in to CaterVLE= $userID
              ";
  
  
  $send = $userEmail;
  $subject = "Log in Details";
  $headers = "Content-type-type: text/html";
  
  
  mail($send, $subject, $content, $headers);
  ?&gt;
  </code></pre>
  
  <p>I know that is a lot of code to look at, I am seriously not looking anyone to do this for me, I just want to know if I am missing something simple or if I can be pointed in the right direction. The email gets sent OK, its just that the database never gets updated, specifically, the access level never gets updated, say from default 4 to 3. </p>
  
  <p>Anyone able to help? Many Thanks! </p>