用PHP制作设计三个静态页面,分别为用户的注册页面、用户的登录页面、新添图书的插入页面;给出源代码

时间: 2024-03-09 14:49:37 浏览: 19
好的,以下是我用 PHP 制作的三个静态页面的源代码。这里我使用了 HTML、CSS 和 PHP 的组合。代码中包含注释,方便你了解每个部分的作用。 用户注册页面的代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>注册页面</title> <style> /* CSS 样式表,用于美化页面 */ body { font-family: Arial, sans-serif; background-color: #f7f7f7; } form { background-color: #fff; border: 1px solid #ccc; padding: 20px; margin: 50px auto; max-width: 400px; box-shadow: 0px 0px 10px #ccc; } input[type="text"], input[type="password"], input[type="email"] { display: block; margin-bottom: 10px; width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px; } input[type="submit"] { background-color: #4CAF50; color: #fff; padding: 10px; border: none; border-radius: 3px; cursor: pointer; } </style> </head> <body> <?php // 处理表单提交 if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; // 在此处添加注册用户的代码 echo '<p>注册成功!</p>'; } else { // 显示注册表单 ?> <form method="post"> <h1>注册</h1> <label>用户名:</label> <input type="text" name="username" required> <label>密码:</label> <input type="password" name="password" required> <label>确认密码:</label> <input type="password" name="confirm_password" required> <label>电子邮件地址:</label> <input type="email" name="email" required> <input type="submit" value="注册"> </form> <?php } ?> </body> </html> ``` 用户登录页面的代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>登录页面</title> <style> /* CSS 样式表,用于美化页面 */ body { font-family: Arial, sans-serif; background-color: #f7f7f7; } form { background-color: #fff; border: 1px solid #ccc; padding: 20px; margin: 50px auto; max-width: 400px; box-shadow: 0px 0px 10px #ccc; } input[type="text"], input[type="password"] { display: block; margin-bottom: 10px; width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px; } input[type="submit"] { background-color: #4CAF50; color: #fff; padding: 10px; border: none; border-radius: 3px; cursor: pointer; } </style> </head> <body> <?php // 处理表单提交 if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = $_POST['username']; $password = $_POST['password']; // 在此处添加验证用户名和密码的代码 if ($username == 'admin' && $password == '123456') { echo '<p>登录成功!</p>'; } else { echo '<p>用户名或密码错误!</p>'; } } else { // 显示登录表单 ?> <form method="post"> <h1>登录</h1> <label>用户名:</label> <input type="text" name="username" required> <label>密码:</label> <input type="password" name="password" required> <input type="submit" value="登录"> </form> <?php } ?> </body> </html> ``` 新添图书的插入页面的代码: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>新添图书的插入页面</title> <style> /* CSS 样式表,用于美化页面 */ body { font-family: Arial, sans-serif; background-color: #f7f7f7; } form { background-color: #fff; border: 1px solid #ccc; padding: 20px; margin: 50px auto; max-width: 400px; box-shadow: 0px 0px 10px #ccc; } input[type="text"], input[type="file"] { display: block; margin-bottom: 10px; width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px; } input[type="submit"] { background-color: #4CAF50; color: #fff; padding: 10px; border: none; border-radius: 3px; cursor: pointer; } </style> </head> <body> <?php // 处理表单提交 if ($_SERVER['REQUEST_METHOD'] == 'POST') { $name = $_POST['name']; $author = $_POST['author']; $publisher = $_POST['publisher']; $isbn = $_POST['isbn']; $image = $_FILES['image']['name']; // 在此处添加插入图书的代码 echo '<p>插入成功!</p>'; } else { // 显示插入表单 ?> <form method="post" enctype="multipart/form-data"> <h1>新添图书</h1> <label>图书名称:</label> <input type="text" name="name" required> <label>作者:</label> <input type="text" name="author" required> <label>出版社:</label> <input type="text" name="publisher" required> <label>ISBN号:</label> <input type="text" name="isbn" required> <label>图书封面:</label> <input type="file" name="image" required> <input type="submit" value="插入"> </form> <?php } ?> </body> </html> ``` 以上是我用 PHP 制作的三个静态页面的源代码,希望能对你有所帮助。注意,这里的代码只是一个参考,你需要根据自己的实际需求进行修改和完善。

相关推荐

最新推荐

recommend-type

Dreamweaver怎么制作百度搜索栏静态页面?

Dreamweaver怎么制作百度搜索栏静态页面?Dreamweaver中想要设计百度的搜索页面,该怎么设计呢?今天我们就来看看使用dw代码设计百度搜索栏静态页面的教程,需要的朋友可以参考下
recommend-type

JS中静态页面实现微信分享功能

小编使用ajax实现静态页面也能实现微信分享功能,今天小编给大家分享实现代码,对js静态页面微信分享功能感兴趣的朋友参考下本
recommend-type

SpringBoot页面跳转访问css、js等静态资源引用无效解决.docx

解释:SpringBoot项目默认访问根目录有三个分别是: /resources :系统默认的根路径 /static :所有静态资源文件如js、css、jpg、html等文件是可以直接访问的 /templates :此目录下的文件是不可以直接访问的,需要...
recommend-type

JSP页面静态化最普遍用的三种

JSP生成静态HTML页面的最为普遍的三种方法: 前两种比较好理解,看多自然明白,这第三种需对Filter对象进一步理解。
recommend-type

Android中替换WebView加载网页失败时的页面

主要介绍了Android中替换WebView加载网页失败时的页面,非常不错,具有参考借鉴价值,需要的朋友参考下吧
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

hive中 的Metastore

Hive中的Metastore是一个关键的组件,它用于存储和管理Hive中的元数据。这些元数据包括表名、列名、表的数据类型、分区信息、表的存储位置等信息。Hive的查询和分析都需要Metastore来管理和访问这些元数据。 Metastore可以使用不同的后端存储来存储元数据,例如MySQL、PostgreSQL、Oracle等关系型数据库,或者Hadoop分布式文件系统中的HDFS。Metastore还提供了API,使得开发人员可以通过编程方式访问元数据。 Metastore的另一个重要功能是跟踪表的版本和历史。当用户对表进行更改时,Metastore会记录这些更改,并且可以让用户回滚到
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。