WEB第二次实验报告(共8页).doc
精选优质文档-倾情为你奉上实 验 报 告(2014 / 2015 学年 第 二 学期)课程名称Web技术实验名称Web服务端脚本编写实验时间2015年5月13日指导单位南京邮电大学指导教师韩京宇学生姓名班级学号学院(系)计算机学院专 业软件工程专心-专注-专业实 验 报 告实验名称Web服务端脚本编写指导教师韩京宇实验类型课内实验学时2实验时间2015.5.13一、 实验目的和要求实验目的:1. 通过上机实验,熟悉Apache服务器的安装和配置使用方法。2. 掌握php脚本语言,熟练运用php语言进行服务端编程。 二、实验环境(实验设备)EditPlus三、 实验原理及内容<head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content="steacymar"> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Welcome to book seller</title> </head> <body> <form action = "Welcome.php" method = "post"> <h1><font face="黑体">You are welcome</font></h1> <table><tr><td>please input your name: </td><td><input type = "text" name = "name"/></td></tr><tr><td>please input your address: </td><td><input type = "text" name = "address"/></td></tr><tr><td>please input your zip: </td><td><input type = "text" name = "zip"/></td></tr> </table> <p><font face="黑体">please fill in the quantity field of the following form:</font> </p> <table border = "border"><tr><th>book</th><th>publisher</th><th>price</th><th>quantity</th></tr><tr><th>Web technology</th><td>Springer press</td><td>$5.0</td><td><input type = "text" name = "wt" /></td></tr><tr><th>mathematics</th><td>ACM press</td><td>$6.2</td><td><input type = "text" name = "mm" /></td></tr><tr><th>principle of OS</th><td>Science press</td><td>$10</td><td><input type = "text" name = "pOS" /></td></tr><tr><th>Theory of matrix</th><td>High education press</td><td>$7.8</td><td><input type = "text" name = "tom" /></td></tr> </table> <p>payment method:</p> <p> <input type = "radio" name="payment" value = "cash" checked = "checked"/>cash <input type = "radio" name="payment" value = "cheque"/>cheque <input type = "radio" name="payment" value = "credit card"/>credit card </p> <p><input type = "submit" value = "Submit"/><input type = "reset" value = "Reset"/> </p> </form> </body></html> Welcome.php<html><head></head><body>customer name: <?php echo $_POST"name" ?></br>customer address: <?php echo $_POST"address" ?></br>customer zip: <?php echo $_POST"zip" ?></br><table border = "border"><tr><th>book</th><th>publisher</th><th>price</th><th>total cost</th></tr><?php function total($price,$quantity)$total = $price*$quantity;return $total;?><?php if( $_POST"wt" != 0)echo "<tr><th>Web technology</th><td>Springer press</td><td>$5.0</td><td> ".total(5,$_POST"wt")." </td></tr>"if($_POST"mm" != 0) echo"<tr><th>mathematics</th><td>ACM press</td><td>$6.2</td><td>".total(6.2,$_POST"mm")."</td></tr>"if($_POST"pOS" != 0) echo"<tr><th>principle of OS</th><td>Science press</td><td>$10</td><td>".total(10,$_POST"pOS")."</td></tr>"if($_POST"tom" != 0) echo"<tr><th>Theory of matrix</th><td>High education press</td><td>$7.8</td><td>".total(7.8,$_POST"tom")."</td></tr>" ?> </table> <p><?php echo $_POST"name"." has bought ".($_POST"wt"+$_POST"mm"+$_POST"pOS"+$_POST"tom")." books." ?></p><p><?php $sum = 5*$_POST"wt"+6.2*$_POST"mm"+10*$_POST"pOS"+7.8*$_POST"tom"echo $_POST"name"." paid ".$sum."." ?></p><p>paid by <?php echo $_POST"payment"."." ?></p><?php$file = fopen("test.txt","w+");fwrite($file,$_POST"name"."hasbought ".($_POST"wt"+$_POST"mm"+$_POST"pOS"+$_POST"tom")." books.rn");fwrite($file,$_POST"name"." paid ".$sum.".rn");fwrite($file,"paid by ".$_POST"payment".".");fclose($file);?></body></html>实 验 报 告四、 实验结果五、指导教师评语 成 绩批阅人日 期