title: how to call php variables outside php tags
body: <p>i want to call $query somewhere inside the html and this returns undefined. Even after declaring the variable as GLOBAL i still get that error.</p>
  
  <pre><code>&lt;?php
  if($query){
  echo "Nice";
  }
  else {
  echo "Bad";
  }
  ?&gt;
  </code></pre>
  
  <p>The Full PHP</p>
  
  <pre><code>&lt;?php
  if(isset($_POST["Name"])) {
  $con = mysql_connect("localhost","root","pwd", "DB");
  if (!$con){
  die(mysql_error());
  }
  $db_selected = mysql_select_db("DB", $con) or die (mysql_error());
  $Name = preg_replace ('#[^a-z, 1-9 ]#i', '', $_POST['Name']);
  $Slog = preg_replace ('#[^a-z ]#i', '', $_POST['Slog']);
  $GLOBAL['query'] = mysql_query("INSERT INTO profiles (Name, Slog)
  VALUES('$Name', '$Slog')") or die (mysql_error());      
  mysql_close($con);
  }       
  ?&gt;
  </code></pre>
  
  <p>Here's the html with php and the $query im calling.</p>
  
  <pre><code>&lt;form style="width:100px" action="insert.php" method="post"&gt;
  &lt;input type="text" name="Name"&gt;
  &lt;input type="text" name="Slog"&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;p&gt;
  &lt;?php
  if($query){
  echo "Nice";
  }
  else {
  echo "Bad";
  }
  ?&gt;
  &lt;/p&gt;
  </code></pre>