title: PHP script to create web page not working
body: <p>I am learning web development from "PHP and MongoDB Web Development" book and they have given this code snippet for creating a blog post creator.</p>
  
  <pre><code>&lt;?php
  $action = (!empty($_POST['btn_submit']) &amp;&amp;
  ($_POST['btn_submit'] === 'Save')) ? 'save_article'
  : 'show_form';
  switch($action){
  case 'save_article':
  try {
  $connection = new Mongo();
  $database
  = $connection-&gt;selectDB('myblogsite');
  $collection = $database-&gt;
  selectCollection('articles');
  $article = array{
  'title' =&gt; $_POST['title'],
  'content' =&gt; $_POST['content'],
  'saved_at' =&gt; new MongoDate()
  };
  $collection-&gt;insert($article);
  } catch(MongoConnectionException $e) {
  die("Failed to connect to database ".
  $e-&gt;getMessage());
  }
  catch(MongoException $e) {
  die('Failed to insert data '.$e-&gt;getMessage());
  }
  break;
  case 'show_form':
  default:
  }
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "Page on w3.org"&gt;
  &lt;html xmlns="XHTML namespace" xml:lang="en"
  lang="en"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html;
  charset=utf-8"/&gt;
  &lt;link rel="stylesheet" href="style.css"/&gt;
  &lt;title&gt;Blog Post Creator&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="contentarea"&gt;
  &lt;div id="innercontentarea"&gt;
  &lt;h1&gt;Blog Post Creator&lt;/h1&gt;
  &lt;?php if ($action === 'show_form'): ?&gt;
  &lt;form action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"
  method="post"&gt;
  &lt;h3&gt;Title&lt;/h3&gt;
  &lt;p&gt;
  &lt;input type="text" name="title" id="title/"&gt;
  &lt;/p&gt;
  &lt;h3&gt;Content&lt;/h3&gt;
  &lt;textarea name="content" rows="20"&gt;&lt;/textarea&gt;
  &lt;p&gt;
  &lt;input type="submit" name="btn_submit"
  value="Save"/&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;?php else: ?&gt;
  &lt;p&gt;
  Article saved. _id:&lt;?php echo $article['_id'];?&gt;.
  &lt;a href="blogpost.php"&gt;
  Write another one?&lt;/a&gt;
  &lt;/p&gt;
  &lt;?php endif;?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>Save the file as blogpost.php .
  Open another new file in your text editor and put the following CSS rules in it and save it as style.css</p>
  
  <pre><code>body {
  background-color: #e1ddd9;
  font-size: 12px;
  font-family: Verdana, Arial, Helvetica, SunSans-Regular,
  Sans-Serif;
  color:#564b47;
  padding:20px;
  margin:0px;
  text-align: center;
  }
  div#contentarea {
  text-align: left;
  vertical-align: middle;
  margin: 0px auto;
  padding: 0px;
  width: 550px;
  background-color: #ffffff;
  border: 1px #564b47;
  }
  div#innercontentarea{ padding: 10px 50px; }
  div#innercontentarea form input[type=text]{ width: 435px; }
  div#innercontentarea form textarea[name=content] { width: 435px; }
  </code></pre>
  
  <p>When I run that script in localhost,it is just showing a blank page.How to make it work?</p>