title: how to allow users logged in to UPDATE / EDIT their profile settings/information
body: <p>Question at hand:</p>
  
  <p><strong>How do I create the php code to let users who are logged into my site edit/update their profile settings/information?</strong></p>
  
  <p>I have 1 part working correctly for users to change their password, however, have no idea where to start when it comes to allowing users who are logged in to edit/update their other settings such as:</p>
  
  <p><strong>(1)</strong> nickname, 
  <strong>(2)</strong> country, 
  <strong>(3)</strong> date of birth, 
  <strong>(4)</strong> gender, 
  <strong>(5)</strong> motto and 
  <strong>(6)</strong> bio</p>
  
  <hr>
  
  <p>I'll provide the php and html code below that I have that is working for changing password, but I know that I need more to let users change/edit/update their other information.  I tried using what is below as a reference to create the php code for the other information, but it didn't work so I have no idea where to even begin!  Any help will be much appreciated...</p>
  
  <p>PHP reference code:</p>
  
  <pre><code>if($_POST['submit']=='Change')
  {
      $err = array();
      if(!$_POST['password1'] || !$_POST['passwordnew1'])
          $err[] = 'All the fields must be filled in!';
      if(!count($err))
      {
          $_POST['password1'] = mysql_real_escape_string($_POST['password1']);
          $_POST['passwordnew1'] = mysql_real_escape_string($_POST['passwordnew1']);
          $row = mysql_fetch_assoc(mysql_query("SELECT id,username FROM members WHERE username='{$_SESSION['username']}' AND pass='".md5($_POST['password1'])."'"));
          if($row['username'])
      {
          $querynewpass = "UPDATE members SET pass='".md5($_POST['passwordnew1'])."' WHERE username='{$_SESSION['username']}'";
          $result = mysql_query($querynewpass) or die(mysql_error());
          $_SESSION['msg']['passwordchange-success']='* You have successfully changed your password!';
      }
          else $err[]='Wrong password to start with!';
      }
      if($err)
      $_SESSION['msg']['passwordchange-err'] = implode('&lt;br /&gt;',$err);
      header("Location: members.php?id=" . $_SESSION['username']);
      exit;
  }
  </code></pre>
  
  <p>HTML reference code:</p>
  
  <pre><code>&lt;form action="" method="post"&gt; 
      &lt;label class="grey" for="password1"&gt;Current Password:&lt;/label&gt;
      &lt;input class="field" type="password" name="password1" id="password1" value="" size="23" /&gt;
      &lt;label class="grey" for="password"&gt;New Password:&lt;/label&gt;
      &lt;input class="field" type="password" name="passwordnew1" id="passwordnew1" size="23" /&gt;
      &lt;input type="submit" name="submit" value="Change" class="bt_register" style="margin-left: 382px;" /&gt;
        &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;?php
      if($_SESSION['msg']['passwordchange-err'])
      {
          echo '&lt;div class="err"&gt;'.$_SESSION['msg']['passwordchange-err'].'&lt;/div&gt;';
          unset($_SESSION['msg']['passwordchange-err']);
      }
      if($_SESSION['msg']['passwordchange-success'])
      {
          echo '&lt;div class="success"&gt;'.$_SESSION['msg']['passwordchange-success'].'&lt;/div&gt;';
          unset($_SESSION['msg']['passwordchange-success']);
      }
      ?&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So how would I create the php code to make this work for users to be able to edit/update their own profile settings/information from the numeric list I provided above (1-6)?</p>
  
  <p>And I know using mysqli/pdo is a better alternative to use, but I unfortunately need to use the old deprecated mysql_* stuff for this project at this time...</p>
  
  <p>If you need more info, let me know ;)</p>
  
  <p><strong>EDIT</strong>:
  Additional Question,</p>
  
  <p>I'd assume too that I'd need to create variables for each column too such as:</p>
  
  <p>$nickname = $_POST['nickname'];</p>
  
  <p>$country = $_POST['country'];</p>
  
  <p>etc...or is that not correct?</p>
  
  <p><strong>RE-EDIT</strong>:</p>
  
  <p>Would something like this be applicable?</p>
  
  <pre><code>$id = $_SESSION['id'];
  if ($_POST['country']) {
      $country = $_POST['country'];
      $nickname = $_POST['nickname'];
      $DOB = $_POST['DOB'];
      $gender = $_POST['gender'];
      $motto = $_POST['motto'];
      $bio = $_POST['bio'];
      $sql = mysql_query("UPDATE members SET country='$country', nickname='$nickname', DOB='$DOB', gender='$gender', motto='$motto', bio='$bio' WHERE id='$id'"); 
  
  exit;
  }
  
  $sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1");
  while($row = mysql_fetch_array($sql)){
  $country = $row["country"];
  $nickname = $row["nickname"];
  $DOB = $row["DOB"];
  $gender = $row["gender"];
  $motto = $row["motto"];
  $bio = $row["bio"];
  }
  </code></pre>
  
  <p>Or am I way off base?</p>