<body>
????????<?php
????????????$str='';
????????if(isset($_GET['1name']))?{
????????????$name?=?$_GET['1name'];
????????????if?(empty($name))?{
????????????????return?$str?=?"姓名不能為空!";
????????????????if?(is_numeric($name))?{
????????????????????return?$str?=?"姓名不能為數字";
????????????????????if?(isset($_GET['lscore']))?{
????????????????????????$score?=?$_GET['lscore'];
????????????????????????if?(empty($score))?{
????????????????????????????return?$str?=?"成績不能為空";
????????????????????????????if?(is_numeric($score))?{
????????????????????????????????if?($score?<?0?||?$score?>?100)?{
????????????????????????????????????return?$str?=?"成績虛假,son?of?a?bitch";
????????????????????????????????}?else?{
????????????????????????????????????switch?((integer)($score?/?10))//0,1,2,3,...,10
????????????????????????????????????{
????????????????????????????????????????case?10:
????????????????????????????????????????????$str?=?'A+';
????????????????????????????????????????????break;
????????????????????????????????????????case?9:
????????????????????????????????????????????$str?=?'A';
????????????????????????????????????????????break;
????????????????????????????????????????case?8:
????????????????????????????????????????????$str?=?'B';
????????????????????????????????????????????break;
????????????????????????????????????????case?7:
????????????????????????????????????????????$str?=?'C';
????????????????????????????????????????????break;
????????????????????????????????????????case?6:
????????????????????????????????????????????$str?=?'D';
????????????????????????????????????????????break;
????????????????????????????????????????default:
????????????????????????????????????????????$str?=?'fail';
????????????????????????????????????????????break;
????????????????????????????????????}
????????????????????????????????}
????????????????????????????}
????????????????????????}
????????????????????}
????????????????}
????????????}
????????}
?????????>
<form?action="#"?method="get">
????請輸入學生的姓名:
????<input?type="text"??name="1name"?value="<?php?if(!empty($_POST["lname"])){?echo?$_GET["lname"]?;}??>"?/><br?/>
????請輸入學生的成績:
????<input?type="text"??name="1score"?value="<?php?if(!empty($_POST["lscore"])){echo?$_GET["lscore"];}??>"?/><br?/>
????<input?type="submit"?value="提交"?/>
</form>
????????<?php
????????echo?$str;
?????????>
</body>
</html>http://www.xianlaiwan.cn/wenda/detail/333114原問題連鎖
1 回答
已采納

慕仙5610752
TA貢獻20條經驗 獲得超2個贊
1,一個建議,表單接收數據后最好action到一個新頁面做各種判斷
2,method中用的get方式,怎么又判斷post方式的數據吶,你可以用post方式,在接收表單數據的頁面中用post接收,然后
判斷,然后輸出。
- 1 回答
- 0 關注
- 1456 瀏覽
添加回答
舉報
0/150
提交
取消