Simple message board, navigation page and company introduction html5 page source code.

A simple message board source code

Use PHP and MySQL database to store and retrieve message information:

 

index.php:

 

htmlCopy code

 

<!DOCTYPE html> <html> <head> <title>留言板</title> <style type="text/css"> form { margin: 10px; padding: 10px; border: 1px solid gray; background-color: #f9f9f9; } label, textarea { display: block; margin-bottom: 5px; } textarea { width: 100%; height: 100px; } input[type=submit] { margin-top: 10px; } h2 { margin-left: 10px; } .message { margin: 10px; padding: 10px; border: 1px solid gray; background-color: #f9f9f9; } .author { font-weight: bold; } .date { color: gray; font-size: 0.8em; } </style> </head> <body> <h2>留言板</h2> <?php //连接数据库 $conn = mysqli_connect('localhost', 'username', 'password', 'database'); if (!$conn) { die("连接失败: " . mysqli_connect_error()); } //处理表单提交 if (isset($_POST['author']) && isset($_POST['message'])) { $author = $_POST['author']; $message = $_POST['message']; $date = date('Y-m-d H:i:s'); $sql = "INSERT INTO messages (author, message, date) VALUES ('$author', '$message', '$date')"; mysqli_query($conn, $sql); } //查询留言 $sql = "SELECT * FROM messages ORDER BY id DESC"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo '<div class="message">'; echo '<span class="author">' . $row["author"] . '</span>'; echo '<span class="date">' . $row["date"] . '</span>'; echo '<p>' . $row["message"] . '</p>'; echo '</div>'; } } else { echo "<p>还没有留言。</p>"; } mysqli_close($conn); ?> <form method="post"> <label for="author">姓名:</label> <input type="text" name="author" required> <label for="message">留言:</label> <textarea name="message" required></textarea> <input type="submit" value="提交"> </form> </body> </html> 

 

In the code above, we first connect to the MySQL database and use the form to insert a new comment. Then, use a SELECT query to get all the comments and display them on the page. Finally, the database connection is closed using the mysqli_close() function.

 

Note that for greater security, you should validate and sanitize user input, such as using the htmlentities() function to escape HTML entity characters to prevent XSS attacks.

 

 

A simple html5 page source code

Here is an example of a simple HTML5 navigation page, using an unordered list and hyperlinks to create a navigation menu:

 

htmlCopy code

 

<!DOCTYPE html> <html> <head> <title>网站导航</title> <style type="text/css"> body { font-family: Arial, sans-serif; background-color: #f9f9f9; margin: 0; padding: 0; } nav { background-color: #333; color: #fff; padding: 10px; } ul { margin: 0; padding: 0; list-style: none; } li { display: inline-block; margin-right: 10px; } a { color: #fff; text-decoration: none; padding: 5px 10px; border-radius: 3px; transition: background-color 0.3s ease; } a:hover { background-color: #666; } </style> </head> <body> <nav> <ul> <li><a href="#">首页</a></li> <li><a href="#">新闻</a></li> <li><a href="#">博客</a></li> <li><a href="#">论坛</a></li> <li><a href="#">About us</a></li> </ul> </nav> </body> </html> 

 

In the code above, we first define an element named nav and set its background color, font color and padding. We then created an unordered list (ul) and list items (li) each containing a hyperlink (a) pointing to a different page of the website. Finally, we apply some CSS styles to set the appearance and interaction of the navigation menu.

 

You can change the style and things like website links and titles according to your needs.

 

 

A simple company introduction page html5 source code

 

Here is an example of a simple HTML5 company website homepage, including company name, tagline, navigation menu, image carousel, and other content blocks:

 

htmlCopy code

 

<section id="banner"> <div class="container"> <img src="banner.jpg" alt="图片轮播"> <h2> Latest Products Release</h2> <p>Let God be the pain it will be followed by the coaching of the elit. "container"> <h2>我们上服务</h2> <p>It is important that the patient is the patient, and the patient will be followed. Some members should drink only at the end of their lives. Mauris commodo, there is no in the rhonc fringilla, the urn mass said free, there is no amat dignissim elit turpis author. There is no consequence, even the wisdom of the Hendrerit Lacinia. <p> p>The knowledge of the pain itself should be followed by the coaching of the elitist.</p> </li> </ul> </div> </section> <section id="about"> <div class="container"> <h2 >是以我们</h2> <div class="column-left"> <img src="about.jpg" alt="公司介绍"> </div> <div class="column-right"> <h3> Our history</h3> <p>Let the pain itself be important, and it will be followed by the adipiscing elite. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul /h3> <p>The knowledge of the pain itself is important, the coaching elit will be followed. /p> </li> </ul> </div> </section> <section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column -left"> <img src="about.jpg" alt="公司介绍"> </div> <div class="column-right"> <h3>Our history</h3> <p>The story of pain itself it is important to follow the coaching process. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul /h3> <p>The knowledge of the pain itself is important, the coaching elit will be followed. /p> </li> </ul> </div> </section> <section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column -left"> <img src="about.jpg" alt="公司介绍"> </div> <div class="column-right"> <h3>Our history</h3> <p>The story of pain itself it is important to follow the coaching process. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul /li> <li> <h3>服务 3</h3> <p>It is important for the patient to learn, he will follow the coaching of the elit.</p> </li> </ul> </div> </section> <section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column-left"> <img src="about.jpg" alt="公司介绍"> < /div> <div class="column-right"> <h3>Our History</h3> <p>The pain itself is important, and the education system will follow. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul /li> <li> <h3>服务 3</h3> <p>It is important for the patient to learn, he will follow the coaching of the elit.</p> </li> </ul> </div> </section> <section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column-left"> <img src="about.jpg" alt="公司介绍"> < /div> <div class="column-right"> <h3>Our History</h3> <p>The pain itself is important, and the education system will follow. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column-left"> <img src="about.jpg" alt="公司介绍"> </div> <div class="column-right"> <h3>Our History</h3> <p>The pain itself is important, and the education system will follow. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul section id="about"> <div class="container"> <h2>最作我们</h2> <div class="column-left"> <img src="about.jpg" alt="公司介绍"> </div> <div class="column-right"> <h3>Our History</h3> <p>The pain itself is important, and the education system will follow. Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul Some members should drink only at the end of their lives. Mauris commodo, no in the rhonc fringilla, urn mass said free, be amet dignissim elit turpis auctor nul

Supongo que te gusta

Origin blog.csdn.net/linyichao123/article/details/130212314
Recomendado
Clasificación