2025年南京邮电大学双语Web实验报告及实践解析.docx
第四章试验2Web服务端脚本编写
一试验目的
(1)通过上机实践,熟悉Apache服务器的安装和配置使用措施。
(2)掌握PHP脚本語言,纯熟运用PHP語言进行服务器端编程。
二试验环境
硬件:MacbookPro13.3early
软件:Apache+MySQL+PHP7.1.8
编辑器:SublimeText
三试验内容及规定
显示一种图书售卖界面,重要包括一下内容
(1)HTML的标題為“Welcometobookseller”。
(2)页面内容第一行黑体显示“Youarewelcome”。
(3)标签提醒“pleaseinputyourname”,并创立输入框。
(4)标签提醒“pleaseinputyouraddress”,并创立输入框。
(5)标签提醒“pleaseinputyourzip”,并创立输入框。
(6)黑体显示“pleasefillinthequantityfieldofthefollowingform”。
(7)表格提成四列,分别是“book”,“publisher”,“price”,“quantity”,其中包括的信息如表格所示
表4.1图书样表
book
publisher
price
quantity
Webtechnology
Springerpress
$5.0
mathematics
ACMpress
$6.2
principleofOS
Sciencepress
$10
Theoryofmatrix
Higheducationpress
$7.8
(8)quantity采用输入框输入。
(9)显示“paymentmethod”
(10)用单项选择按钮显示四个支付方式选项“cash”,“cheque”,“creditcard”。
(11)显示两个原则按钮,“submit”按钮和“reset”按钮。
当顾客输入完各个内容并按下“submit”按钮后,通过脚本生成新的HTML页面。其中包括如下内容
customername
customeraddress
customerzip
(4)以表格形式显示订购图书信息,包括四列“book”,“publisher”,“price”,“totalcost”,其中totalcost通过脚本动态计算生成。未购置的图书不显示。
(5)计算并显示“××hasbought××books”。(××分别指代客户名字和购置书的数量)
(6)计算并显示“××paid××”。(这里××指代客户名字和总金额数)
(7)根据顾客的选择显示“paidby××”。(这里×指代顾客选择的支付方式)
将顾客购置信息存入到文献中,每个客户包括三行信息,既2中的(5)(6)(7)三句话。
假如顾客按的是“重置”按钮,则清除所有的输入信息。
四试验过程
编写index.html,重要包括一下内容
(1)采用HTML的head表达。
head
titleWelcometobookseller/title
/head
(2)采用h1标签。
h1Youarewekcome!/h1
(3)(4)(5)采用tr/tr中嵌套td/td,td/td中嵌套input标签实現。
(7)表格采用table标签实現。
tableborder=1pxpadding=1px
tr
thbook/th
thpublisher/th
thprice/th
thquantity/th
/tr
tr
tdWebtechnology/td
tdSpringPress/td
td$5.0/td
td
inputtype=textname=WTsize=30/
/td
/tr
tr
tdMathmatics/td
tdACMPress/td
td$6.2/td
td
inputtype=textname=Masize=30