Advertisement
dimipan80

Print Tags

Dec 2nd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <!--Write a PHP script PrintTags.php which generates an HTML input text field and a submit button.
  2. In the text field the user must enter different tags, separated by a comma and a space (", ").
  3. When the information is submitted, the script should split the tags, put them in an array and
  4. print out the array. Semantic HTML is required. Styling is not required.-->
  5.  
  6. <!DOCTYPE html>
  7. <html>
  8. <head lang="en">
  9.     <meta content="text/html" charset="UTF-8">
  10.     <title>Print Tags</title>
  11. </head>
  12. <body>
  13. <form action="#" method="get">
  14.     <p><label for="tags">Enter Tags:</label></p>
  15.     <input type="text" name="tags" id="tags" required/>
  16.     <input type="submit" value="Submit"/>
  17. </form>
  18. <?php
  19. if ($_GET && $_GET['tags']) {
  20.     $tags = explode(', ', trim($_GET['tags']));
  21.  
  22.     foreach ($tags as $key => $tag) {
  23.         echo "<p>$key : " . htmlspecialchars($tag) . "</p>\n";
  24.     }
  25. }
  26. ?>
  27. </body>
  28. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement