title: Edit profile - PDO
body: <p>I'm trying to include in my script the page to change the details of the user profile. I did it this way, in the class user.php I included this:</p>
  
  <pre><code>// Update profile
      public function update($email,$gender,$location) {
          try {
          $stmt = $this-&gt;_db-&gt;prepare('UPDATE members SET email = ?, gender = ?, location = ? WHERE memberID = ? ');
          $stmt-&gt;execute(array($email,$gender,$location,$_SESSION['memberID']));
          return $stmt-&gt;fetch();
          } catch(PDOException $e) {
              echo '&lt;p class="bg-danger"&gt;'.$e-&gt;getMessage().'&lt;/p&gt;';
          }
      }
  </code></pre>
  
  <p>While, for example, the page account.php I did it this way:</p>
  
  <pre><code>if (isset($_POST['submit'])) {
  // new data
  $email = $_POST['email'];
  $gender = $_POST['gender'];
  $location = $_POST['location'];
      $id = $_SESSION['memberID'];
  
  // query
  if ($user-&gt;update($email,$gender,$location,$id)); {
      redirect('account.php');
  }
  }
  </code></pre>
  
  <p>And,</p>
  
  <pre><code>&lt;form action="account.php" method="POST"&gt;
  Email&lt;br&gt;
  &lt;input type="text" name="email" value="&lt;?php echo $_SESSION['email'] ?&gt;" /&gt;&lt;br&gt;
  Gender&lt;br&gt;
  &lt;input type="text" name="gender" value="&lt;?php echo $_SESSION['gender'] ?&gt;" /&gt;&lt;br&gt;
  Location&lt;br&gt;
  &lt;input type="text" name="location" value="&lt;?php echo $_SESSION['location'] ?&gt;" /&gt;&lt;br&gt;
  &lt;input type="submit" name="submit" value="Save" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Use a connection in PDO from how it is understood, however, I have tried many options but always with poor results.</p>