Venciity

HTML Tags Counter

Aug 17th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>HTML Tags Counter</title>
  6. </head>
  7. <body>
  8. <form action="" method="post">
  9.     <label for="tag">Enter HTML tags:</label> <br />
  10.     <input type="text" name="tag" id="tagBox"/>
  11.     <input type="submit" value="submit" name="submit"/>
  12.     <div id="output"></div>
  13. </form>
  14. <?php
  15.     session_start();
  16.     $validTags = array('a', 'abbr', 'acronym', 'address', 'applet', 'area', 'b', 'base', 'basefont',
  17.         'bdo', 'bgsound', 'big', 'blockquote', 'blink', 'body', 'br', 'button', 'caption', 'center', 'cite', 'code',
  18.         'col', 'colgroup', 'dd', 'dfn', 'del', 'dir', 'dl', 'div', 'dt', 'embed', 'em', 'fieldset', 'font', 'form',
  19.         'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'iframe', 'img', 'input',
  20.         'ins', 'isindex', 'i', 'kbd', 'label', 'legend', 'li', 'link', 'marquee', 'menu', 'meta', 'noframe',
  21.         'noscript', 'optgroup', 'option', 'ol', 'p', 'pre', 'q', 's', 'samp', 'script', 'select', 'small', 'span', 'strike',
  22.         'strong', 'style', 'sub', 'sup', 'table', 'td', 'th', 'tr', 'tbody', 'textarea', 'tfoot', 'thead', 'title',
  23.         'tt', 'u', 'ul', 'var');
  24.     $_SESSION['count'] = 0;
  25.     $message = "";
  26.     if (isset($_POST['tag'])) {
  27.         $tagName = $_POST['tag'];
  28.         if (in_array($tagName , $validTags)) {
  29.             $_SESSION['count']++;
  30.             $message = "Valid HTML tag! <br /> Score: ". $_SESSION['count'];
  31.         }
  32.         else {
  33.             $message = "Invalid HTML tag! <br /> Score: ". $_SESSION['count'];
  34.         }
  35.     }
  36.     echo "$message";
  37. ?>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment