title: PHP Edit Post with Google OpenID
body: <p>I'm trying to code an edit post page for my site which posts to itself using a google openid logon, however i just get a blank page, instead of the edit form. Here's the code i'm using:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;BQuotes&lt;/title&gt;
      &lt;!-- &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; --&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /&gt;
      &lt;link href="votingfiles/voting.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="votingfiles/voting.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="http://bquotes.me/mystyle-a.css"&gt;
      &lt;script src="http://code.jquery.com/jquery-1.10.0.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"&gt;&lt;/script&gt;
      &lt;style&gt;
        .head_text {
          color: #ffffff;
        }
        a {
          text-decoration: none;
        }
      &lt;/style&gt;
  
      &lt;script type="text/javascript"&gt;
        $('#g-login').bind('click', function (event) {
          // event.preventDefault();
          // $('#form-id').attr('action', 'google-login.php').trigger('submit');
          alert("Clicked");
        });
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body style="color:#d4ffaa"&gt;
  
  
      &lt;!-- BQ Edit Post Start --&gt;
      &lt;div data-role="page" id="editPost"&gt;
        &lt;div data-role="header" style="background-color:#5FBF00"&gt;
          &lt;h1 class="head_text"&gt;BQuotes: Edit Statuses&lt;/h1&gt;
        &lt;/div&gt;
        &lt;div data-role="main" class="ui-content"&gt;
  
          &lt;?php
  
  
  
  
  
            ?&gt;
  
  
        &lt;/div&gt;
  
  
  
           &lt;?php
            define ('HOSTNAME', 'host');
            define ('USERNAME', 'user');
            define ('PASSWORD', 'pass');
            define ('DATABASE_NAME', 'db');
  
            $db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to MySQL.');
  
            mysql_select_db(DATABASE_NAME);
  
            $tbl='table';
            $id=$_POST['pid'];
  
            $query="SELECT * from $tbl WHERE $id=id";
            $result = mysql_query($query);
  
            while($row = mysql_fetch_array($result)) {
            $id=$row['id'];
            $username=$row['username'];
            $message=$row['message'];
            $tag=$row['tag'];
  
  
  
           session_start();
                if($_SESSION['myusername'] != null &amp;&amp;  isset($_SESSION['myusername'])){
                echo "&lt;form action='logout.php' method='post' id ='form-logout' data-ajax='false'&gt;
                      &lt;br/&gt;&lt;input type='submit' value='Logout'/&gt;";
                echo "&lt;/form&gt;";
                echo "&lt;div style='margin-left:20px;'&gt;Logged In As:  ".$_SESSION['myusername']."&lt;/div&gt;";
  
               echo "&lt;form name='post-edit' action='' method='post'&gt;";
               echo "&lt;input type='hidden' name='id' value=".$row['id']."&gt;";
               echo "&lt;input type='hidden' name='username' value=".$row['username']."&gt;";
               echo "&lt;textarea name='message' value=".$row['message']."&gt;";
               echo "&lt;input type='text' name='tag' value=".$row['tag']."&gt;";
               echo "&lt;input type='submit' name='submit' value='Edit!'&gt;";
               echo "&lt;/form&gt;";
  
                }
              else if($_SESSION['myusername'] == null){
                echo "&lt;form action='google-login.php?login=true' method='post' id ='form-id' data-ajax='false'&gt;";    
                   echo "&lt;span class='loginreq'&gt;Login to Edit&lt;/span&gt;";           
                  echo "&lt;br/&gt;&lt;input type='submit' value='Login with Google'/&gt;";
                  echo "&lt;/form&gt;";
              }
              }
  
  
  
            if (isset($_POST['submit'])) {
  
            $query = "UPDATE mybq_post_txt_main SET message=$message, tag=$tag WHERE id=$id ";
  
            $result = mysql_query($query);
  
            while ($row = mysql_fetch_array($result)) {
  
            echo "Your post has been edited to:";&lt;br&gt;
            echo $row['message'];
            echo $row['tag'];
            }
  
            mysql_free_result($result);
            mysql_close();
  
            }
  
          ?&gt;
  
  
  
          &lt;a href='mybq-index.php'&gt;Home&lt;/a&gt;
  
  
        &lt;/div&gt;
  
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any help will be appreciated. (never mind the PHP SQL statements, I will convert them to PDO later).</p>