topical media & game development

talk show tell print

professional-sql-10-public-files-post.php / php



  <?php
  // include shared code
  include '../lib/common.php';
  include '../lib/db.php';
  
  // validate incoming values
  name = (isset(_POST['person_name'])) ? trim(_POST['person_name']) : '';
  comment = (isset(_POST['post_comment'])) ? trim(_POST['post_comment']) : '';
  
  if (name && comment)
  {
      // add comment
      query = sprintf('INSERT INTO \%sBLOG_COMMENT (POST_ID, PERSON_NAME, ' .
          'POST_COMMENT) VALUES (\%d, "\%s", "\%s")',
          DB_TBL_PREFIX,
          _GET['id'],
          htmlspecialchars(name),
          htmlspecialchars(comment));
      mysql_query(query, GLOBALS['DB']);
      echo 'OK';
  }
  else
  {
      echo 'ERR';
  }
  mysql_close(GLOBALS['DB']);
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.