Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Write a PHP program SidebarBuilder.php that takes data from several input fields and builds 3 sidebars.
- The input fields are categories, tags and months. The first sidebar should contain a list of the categories,
- the second sidebar – a list of the tags and the third should contain the months.
- The entries in the input strings will be separated by a comma and space ", ".
- Styling the page is optional. Semantic HTML is required.-->
- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title>Sidebar Builder</title>
- <style type="text/css">
- section {
- width: 60%;
- float: left;
- }
- input[type="text"] {
- width: 300px;
- text-indent: 2px;
- }
- aside {
- width: 35%;
- float: right;
- }
- article {
- width: 80%;
- font-family: Tahoma, sans-serif;
- font-size: 18px;
- background-color: #FF0;
- padding: 5px 0 5px 15px;
- margin-bottom: 10px;
- border: 1px solid #000;
- border-radius: 20px;
- }
- h2 {
- border-bottom: 1px solid #000;
- }
- ul {
- list-style-type: circle;
- }
- li {
- text-decoration: underline;
- }
- </style>
- </head>
- <body>
- <section>
- <form method="post">
- <p>
- <label for="cats">Categories:</label>
- <input type="text" name="cats" id="cats" autofocus required/>
- </p>
- <p>
- <label for="tags">Tags:</label>
- <input type="text" name="tags" id="tags" required/>
- </p>
- <p>
- <label for="months">Months:</label>
- <input type="text" name="months" id="months" required/>
- </p>
- <input type="submit" value="Generate"/>
- </form>
- <p>
- <?php
- if (!isset($_POST['cats']) || !isset($_POST['tags']) || !isset($_POST['months']) ||
- trim($_POST['cats']) === '' || trim($_POST['tags']) === '' || trim($_POST['months']) === ''
- ) {
- die('Please, enter some text in Each Text-field on Input Form!!!');
- }
- ?>
- </p>
- </section>
- <?php
- $categories = preg_split('/,\s+/', trim($_POST['cats']), -1, PREG_SPLIT_NO_EMPTY);
- $tags = preg_split('/,\s+/', trim($_POST['tags']), -1, PREG_SPLIT_NO_EMPTY);
- $months = preg_split('/,\s+/', trim($_POST['months']), -1, PREG_SPLIT_NO_EMPTY);
- ?>
- <aside>
- <article>
- <h2>Categories</h2>
- <ul>
- <?php
- foreach ($categories as $categ):?>
- <li><?= htmlspecialchars($categ) ?></li>
- <?php endforeach; ?>
- </ul>
- </article>
- <article>
- <h2>Tags</h2>
- <ul>
- <?php
- foreach ($tags as $tag):?>
- <li><?= htmlspecialchars($tag) ?></li>
- <?php endforeach; ?>
- </ul>
- </article>
- <article>
- <h2>Months</h2>
- <ul>
- <?php
- foreach ($months as $month):?>
- <li><?= htmlspecialchars($month) ?></li>
- <?php endforeach; ?>
- </ul>
- </article>
- </aside>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement