1 / 7

4 實例應用:問卷調查

4 實例應用:問卷調查. 2 指導老師:黃鈴玲 2 學 生:林志彥. 2004/12/15. 問卷調查. 問卷調查是一種常見的表單應用,提供網站管理者一種取得網友資料的管道,網友能夠直接在表單輸入資料填寫相關的問卷內容。 本範例將資料寫入 questions.list 檔案. 進入問卷調查. questions.htm. questions.php. viewquestions.php. questions.list. if (!($name == "" || $email == "" )) { // 取得填寫問卷的日期與時間

Télécharger la présentation

4 實例應用:問卷調查

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 4實例應用:問卷調查 2指導老師:黃鈴玲 2學 生:林志彥 2004/12/15

  2. 問卷調查 • 問卷調查是一種常見的表單應用,提供網站管理者一種取得網友資料的管道,網友能夠直接在表單輸入資料填寫相關的問卷內容。 • 本範例將資料寫入questions.list檔案 進入問卷調查 questions.htm questions.php viewquestions.php questions.list

  3. if (!($name == "" || $email == "" )) { • // 取得填寫問卷的日期與時間 • $today = date("Y年m月d日 星期w h:i:s a"); • // 顯示使用者填寫的內容 • echo $name . $male.",您的問卷填寫內容如下:<p>"; • echo "填寫日期:".$today."<br>"; • echo "年齡:".$age."<br>"; • echo "所在地:".$location."<br>"; • echo "聯絡電話:".$phone."<br>"; • echo "電子郵件:".$email."<br>"; • echo "您的意見:".$comment."<br><hr>"; • // 寫入問卷填寫文字檔案 • $file = fopen($quizfile, "a+"); • fputs($file,$name."||".$male."||".$today."||". • $location."||".$phone."||".$email."||".$comment."\r\n"); • fclose($file); • } • else • echo "必須輸入姓名和電子郵件欄位!"; • ?> • <a href="viewquestions.php">檢視問卷調查結果</a> • </body> • </html> question.php • <!-- 程式範例:questions.php --> • <html> • <head> • <title>問卷調查處理程式</title> • </head> • <body bgcolor="#CCFF88"> • <center><h2>問卷調查內容</h2><hr></center> • <? • // 設定儲存問卷填寫內容的文字檔 • $quizfile = "questions.list"; • // 取得問卷填寫內容的資料 • $name = $_POST["nname"]; • $age = $_POST["aage"]; • $male = $_POST["mmale"]; • $location = $_POST["llocation"]; • $phone = $_POST["pphone"]; • $email = $_POST["eemail"]; • $comment = stripslashes($_POST["ccomment"]);

  4. viewquestion.php • <!-- 程式範例:viewquestions.php --> • <html> • <head> • <title>顯示問卷內容</title> • </head> • <body bgcolor="#CCFF88"> • <center><h2>顯示問卷內容</h2><hr></center> • <? • // 設定儲存問卷填寫內容的文字檔 • $quizfile = "questions.list"; • // 取得問卷填寫內容的資料到陣列 • $fdatas = file($quizfile); • ?> • <table border="1"> • <tr><td>姓名</td><td>性別</td><td>填寫日期</td> • <td>所在地</td><td>聯絡電話</td><td>E-Mail</td> • <td>意見</td></tr> • <? • while (list($linenum, $line) = each($fdatas)) { • $quizlist = explode("||" , $line); • $intmax = count($quizlist); • echo "<tr>"; • for ($i = 0;$i < $intmax; $i++) • echo "<td>".$quizlist[$i]."</td>"; • echo "<tr>"; • } • ?> • </table> • </body> • </html>

  5. question.htm • <input type="radio" name="Location" value="中部地區">中部地區 • <input type="radio" name="Location" value="南部地區">南部地區 • <input type="radio" name="Location" value="花東地區">花東地區 • <input type="radio" name="Location" value="離島地區">離島地區 • </td></tr> • <tr valign="top"><td align="right">聯絡電話:</TD><TD> • <input type="text" name="Phone"> • </td></tr> • <tr valign="top"><td align="right"><font color="red">* </font> • 電子郵件:</td><td> • <input type="text" name="Email"> • </td></tr> • <tr valign="top"><td align="right">意見:</td><td> • <textarea cols="35" name="Comment" rows="4"> • </textarea> • </td></tr> • <tr valign="top"><td colspan="2"> • <input type="submit" value="送出問卷"> • </td></tr> • </table> • </form> • </center> • </body> • </html> <!-- 程式範例:questions.htm --> <html> <head> <title>問卷調查</title> </head> <body bgcolor="#CCFF88"> <center><h2>問卷調查</h2> <hr> <form method="post" action="questions.php"> <table border="0"> <tr valign="top"><td align="right"> <font color="red">* </font>姓名: </td><td><input type="text" name="Name"> </td></tr> <tr valign="top"><td align="right">您的年齡:</td><td> <input type="radio" name="Age" value="10以下">10以下 <input type="radio" name="Age" value="11~20">11~20 <input type="radio" name="Age" value="21~30" checked>21~30 <input type="radio" name="Age" value="31~40">31~40 <input type="radio" name="Age" value="41~50">41~50 <input type="radio" name="Age" value="50以上">50以上 </td></tr> <tr valign="top"><TD align="right">性別:</td><td> <input type="radio" name="Male" value="先生" checked>先生 <input type="radio" name="Male" value="小姐">小姐 </td></tr> <tr valign="top"><td align="right">所在地:</td><td> <input type="radio" name="Location" value="北部地區" checked> 北部地區

  6. question.list範例 陳峰棋||先生||2003年06月20日 星期5 03:10:54 am||北部地區||02-2393-6329||colin28@seed.net.tw||好書值得大家推薦! 陳會安||先生||2003年06月20日 星期5 03:11:59 am||北部地區||02-2393-6329||hueyan@ms2.hinet.net||這是一本好書! 江小魚||小姐||2003年06月20日 星期5 03:23:18 am||中部地區||05-5555-5555||fish@ms11.hinet.net||測試問卷調查

  7. Thank you!

More Related