title: php error on localhost: Access forbidden! error 403
body: <p>I am following <a href="http://www.hardcoder.com/scripting/php/guestbook/index.php" rel="nofollow">this</a> php tutorial on windows7 using XAMPP.<br>
  It's a guest book tutorial that saves user entries into mysql &amp; displays entries from db.
  when I enter data into form &amp; submit it, browser shows this error msg </p>
  
  <p><strong>Access forbidden!</strong>
  <em>You don't have permission to access the requested object. It is either read-protected or not readable by the server.
  If you think this is a server error, please contact the webmaster.</em> 
  <strong>Error 403</strong>
  localhost
  <em>Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7</em>  </p>
  
  <p><strong>UPDATED</strong> </p>
  
  <p><strong>guestbok.php</strong></p>
  
  <blockquote>
    <p>Connect to DB Code</p>
  </blockquote>
  
  <pre><code>&lt;?php
  $dbHost = "localhost";
  $dbUser = "root";
  $dbPass = "";
  $dbDatabase = "myDB";
  
  // Connect to DB
  
  $li = new mysqli('localhost', 'root', '', 'myDB') or 
        die("Could not connect". mysqli_connect_error());
  //mysql_select_db($dbDatabase, $li) or 
        die ("could not select DB". mysql_error());
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Variables initialisation</p>
  </blockquote>
  
  <pre><code>&lt;?php
  // initiate some vars
  
  $gb_str = "";   
  // $gb_str is the string we'll append entries to
  $pgeTitle = "View and Sign Guestbook";
  </code></pre>
  
  <blockquote>
    <p>Post request handling</p>
  </blockquote>
  
  <pre><code>// If form is submitted, then insert into DB
  if (!empty($_POST["submit"])) {
      $name = $_POST["frmName"];
      $email = $_POST["frmEmail"];
      $comment = $_POST["frmComment"];
      $date = Date("Y-m-d h:i:s");
  
      $gb_query =     "insert into guestbook
              values(0, '$name', '$email', '$comment', '$date')";
      // Performs the $sql query on the server to insert the values
      if ($li-&gt;query($gb_query) === TRUE) {
          echo 'users entry saved successfully';
      }
      else {
          echo 'Error: '. $li-&gt;error;
      }
      /*
      $sql = mysql_query($gb_query);
      $res = mysql_affected_rows($sql);
  
      // See if insert was successful or not
      if($res &gt; 0) {
          $ret_str="Your guestbook entry was successfully added.";
      } else {
          $ret_str = "Your guestbook entry was NOT successfully added.";
      }
  
      // Append success/failure message
      $gb_str .= "&lt;span class=\"ret\"&gt;$ret_str&lt;/span&gt;&lt;BR&gt;";
      */
  }
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>GuestBook list</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  $get_query = "select gbName, gbEmail, gbComment, 
                DATE_FORMAT(gbDateAdded, '%m-%d-%y %H:%i') gbDateAdded
                from guestbook";
  
  $result = $li-&gt;query($get_query);
  $gb_str .= "&lt;hr size=\"1\"&gt;";
  
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row from $result
      while($row = $result-&gt;fetch_assoc()) {
      $name = $row["gbName"];
      $email = $row["gbEmail"];
      $comment = $row["gbComment"];
      $date = $row["gbDateAdded"];
  
      if(!empty($name)) {
          // If name exists and email exists, link name to email
          if(!empty($email)) {
              $name="by &lt;a href=\"mailto:$email\"&gt;$name&lt;/a&gt;";
          }
      // If name does exist and email exists, link email to email     
      } else if (!empty($email)) {
          $name = "by &lt;a href=\"mailto:$email\"&gt;$email&lt;/a&gt;";
      } else {
          $name = "";
      }
  
      // Append to string we'll print later on
      $gb_str .= "&lt;br&gt;$comment&lt;p class=\"small\"&gt;
                  posted on $date $name&lt;hr size=\"1\"&gt;";
  }}
  
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>The HTML Page</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt; 
  &lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt;Guestbook&lt;/TITLE&gt;
  &lt;SCRIPT language="javascript"&gt;
  &lt;!--
  
  /* This function is pulled from a generic validation file from
  some other site (probably developer.netscape.com) and strips out
  characters you don't want */
  
  function stripCharsInBag (s, bag) {
      var i;
      var returnString = "";
  
      // Search through string's characters one by one.
      // If character is not in bag, append to returnString.
  
      for (i = 0; i &lt; s.length; i++)
      {   
          // Check that current character isn't whitespace.
          var c = s.charAt(i);
          if (bag.indexOf(c) == -1) returnString += c;
      }
      return returnString;
  }
  
  // This function just makes sure the comment field is not empty
  
  function valForm(frm) {
      badChars = "&lt;[]&gt;{}";
      if(frm.frmComment.value == "") {
          alert("Please fill in your comments for the guestbook.");
          return false;
      } else {
          frm.frmComment.value = stripCharsInBag(frm.frmComment.value, badChars);
          // These values may be empty, but strip chars in case they're not
          frm.frmName.value = stripCharsInBag(frm.frmName.value, badChars);
          frm.frmEmail.value = stripCharsInBag(frm.frmEmail.value, badChars);
          return true;
      }
  }
  
  --&gt;
  &lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  
  &lt;BODY bgcolor="#FFFFFF"&gt;
  &lt;?php echo $gb_str; ?&gt;
  
  &lt;form name="gb" action="&lt;? echo $PHP_SELF;?&gt;" method="post"&gt;
  &lt;table cellpadding="3" cellspacing="0" border="0"&gt;
    &lt;tr&gt;
      &lt;td class="tdhead" valign="top" align="right"&gt;Name&lt;/td&gt;
      &lt;td valign="top"&gt;
        &lt;input type="text" name="frmName" value="" size="30" 
               maxlength="50"&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td class="tdhead" valign="top" align="right"&gt;Email&lt;/td&gt;
      &lt;td valign="top"&gt;
        &lt;input type="text" name="frmEmail" value="" size="30" 
               maxlength="100"&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td class="tdhead" valign="top" align="right"&gt;Comment&lt;/td&gt;
      &lt;td valign="top"&gt;
          &lt;textarea name="frmComment" rows="5" cols="30"&gt;&lt;/textarea&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" name="submit" value="submit" 
                 onClick="return valForm(document.gb)"&gt;
          &lt;input type="reset" name="reset" value="reset"&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  
  &lt;?php
  // Close MySQL Connection
  $li-&gt;close();
  ?&gt;
  </code></pre>