title: Modifying MySQL entry based on logged in user
body: <p>Evening once again fellow stack over flowers,</p>
  
  <p>I have been given this code to use by @sman591:</p>
  
  <pre><code>$current_user_id = get_current_user_id(); // current user logged into WordPress
  
  mysql_query("UPDATE `table` SET `user_id`='$current_user_id' WHERE `id`='$entry_id'") or die(mysql_error());
  
  $query = mysql_query("SELECT * FROM `table` WHERE `id`='$entry_id' LIMIT 1") or die(mysql_error());
  $data = mysql_fetch_array($query);
  
  $allowed_user_edit_id = $data['id']; // user id who is allowed to edit
  
  $current_user_id = get_current_user_id(); // current user logged into WordPress
  
  if ($current_user_id == $allowed_user_edit_id) {
      // Your code for editing the entry
  }
  </code></pre>
  
  <p>This code is to complement my modifyame.php (wrapped in a Wordpress template)</p>
  
  <pre><code>&lt;?php
  /**
   * The template for displaying all pages.
   * Template Name: modifyame.php
   * This is the template that displays all pages by default.
   * Please note that this is the WordPress construct of pages
   * and that other 'pages' on your WordPress site will use a
   * different template.
   *
   * @package WordPress
   * @subpackage Twenty_Twelve
   * @since Twenty Twelve 1.0
   */
  
  get_header(); ?&gt;
  
  
      &lt;div id="primary" class="site-content"&gt;
          &lt;div id="content" role="main"&gt;
  
  
              &lt;?php while ( have_posts() ) : the_post(); ?&gt;
                  &lt;?php get_template_part( 'content', 'page' ); ?&gt;
                  &lt;?php comments_template( '', true ); ?&gt;
  
              &lt;?php endwhile; // end of the loop. ?&gt;
  
  
  
  &lt;?php
  
  
  mysql_connect("localhost", "herp", "derp") or die (mysql_error());
  echo "Connected to MYSQL ";
  mysql_select_db("diddly") or die (mysql_error());
  echo "Connected to Data Base";
  
  
  if(!isset($_POST['submit'])) {
      $q = "SELECT * FROM addserverame WHERE ID = $_GET[id]";
      $result = mysql_query ($q);
      $person = mysql_fetch_array ($result);
      }
  
      ?&gt;
  
          &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Add Your Server&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="view.css" media="all"&gt;
  &lt;script type="text/javascript" src="view.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body id="main_body" &gt;
  
      &lt;img id="top" src="top.png" alt=""&gt;
      &lt;div id="form_container"&gt;
  
          &lt;h1&gt;&lt;a&gt;Modify Server&lt;/a&gt;&lt;/h1&gt;
          &lt;form id="form_606591" class="appnitro"  method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
                      &lt;div class="form_description"&gt;
              &lt;h2&gt;Add Your Server&lt;/h2&gt;
              &lt;p&gt;&lt;/p&gt;
          &lt;/div&gt;                      
              &lt;ul &gt;
  
                      &lt;li id="li_1" &gt;
          &lt;label class="description" for="servername"&gt;Server Name &lt;/label&gt;
          &lt;div&gt;
              &lt;input id="element_1" name="Servername" class="element text medium" type="text" maxlength="255" value="&lt;?php echo $person['servername']; ?&gt;"/&gt; 
          &lt;/div&gt;&lt;p class="guidelines" id="guide_1"&gt;&lt;small&gt;Enter your server name here NOT your server address.&lt;/small&gt;&lt;/p&gt; 
          &lt;/li&gt;       &lt;li id="li_2" &gt;
          &lt;label class="description" for="Serveraddress"&gt;Server Address &lt;/label&gt;
          &lt;div&gt;
              &lt;input id="element_2" name="Serveraddress" class="element text medium" type="text" maxlength="255" value="&lt;?php echo $person['serveraddress']; ?&gt;"/&gt; 
          &lt;/div&gt;&lt;p class="guidelines" id="guide_2"&gt;&lt;small&gt;This will the DNS name of your server&lt;/small&gt;&lt;/p&gt; 
          &lt;/li&gt;       &lt;li id="li_3" &gt;
          &lt;label class="description" for="Portnumber"&gt;PortNumber &lt;/label&gt;
          &lt;div&gt;
              &lt;input id="element_3" name="Portnumber" class="element text medium" type="text" maxlength="255" value="&lt;?php echo $person['portnumber']; ?&gt;"/&gt; 
          &lt;/div&gt;&lt;p class="guidelines" id="guide_3"&gt;&lt;small&gt;This will be the port your server is using.&lt;/small&gt;&lt;/p&gt; 
          &lt;/li&gt;       &lt;li id="li_4" &gt;
          &lt;label class="description" for="Description"&gt;Server Description &lt;/label&gt;
          &lt;div&gt;
              &lt;textarea id="element_4" name="Description" class="element textarea medium" value ="&lt;?php echo $person['description']; ?&gt;"&gt;&lt;/textarea&gt; 
          &lt;/div&gt;&lt;p class="guidelines" id="guide_4"&gt;&lt;small&gt;Enter server description/rules here.&lt;/small&gt;&lt;/p&gt; 
          &lt;/li&gt;
  
                      &lt;li class="buttons"&gt;
                  &lt;input type="hidden" name="id" value="&lt;?php echo $_GET['id']; ?&gt;" /&gt;
  
                  &lt;input id="saveForm" class="button_text" type="submit" name="submit" value="Modify" /&gt;
          &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/form&gt; 
          &lt;div id="footer"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;/body&gt;-
  &lt;/html&gt;
  
  &lt;?
  
  if(isset($_POST['submit'])) {
      $u = "UPDATE addserverame SET `servername`='$_POST[Servername]', `serveraddress`='$_POST[Serveraddress]', `portnumber`='$_POST[Portnumber]', `description`='$_POST[Description]' WHERE ID = $_POST[id]";
      mysql_query($u) or die (mysql_error());
      echo "Server Info Has Been Modified";
  }
  ?&gt;
  
      &lt;/div&gt;&lt;!-- #primary --&gt;
          &lt;/div&gt;&lt;!-- Content --&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p><strong>The problem</strong></p>
  
  <p>I am having a problem merging the two so that the conditions from sman are checked before and verified before the conditions of modifyame.php, my main problem is i am not very familiar with the syntax rules of PHP, I placed the login verify code above the other if statement and tried wrapping the statement inside the other.</p>
  
  <p><strong>What I'm asking</strong></p>
  
  <p>Can someone please merge them correctly?</p>
  
  <p><strong>NOTE</strong> I thought it would be easier displaying them separate then my attempt (less 
  confusing)</p>