<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml">
<head>
????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
????<title>無(wú)標(biāo)題文檔</title>
????<style?type="text/css">
????????body{
????????????font-size:18px;
????????}
????</style>
</head>
<body>
????????<?php
????????????$str='';
????????if(isset($_GET['1name']))?{
????????????$name?=?$_GET['1name'];
????????????if?(empty($name))?{
????????????????$str?=?"姓名不能為空!";
????????????}?else?{
????????????????if?(is_numeric($name))?{
????????????????????$str?=?"姓名不能為數(shù)字";
????????????????}?else?{
????????????????????if?(isset($_GET['lscore']))?{
????????????????????????$score?=?$_GET['lscore'];
????????????????????????if?(empty($score))?{
????????????????????????????$str?=?"成績(jī)不能為空";
????????????????????????}?else?{
????????????????????????????if?(is_numeric($score))?{
????????????????????????????????if?($score?<?0?||?$score?>?100)?{
????????????????????????????????????$str?=?"成績(jī)虛假,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">
????請(qǐng)輸入學(xué)生的姓名:
????<input?type="text"??name="1name"?value="<?php?if(!empty($_POST["lname"])){?echo?$_GET["lname"]?;}??>"?/><br?/>
????請(qǐng)輸入學(xué)生的成績(jī):
????<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>不能判斷成績(jī),求告訴我哪里錯(cuò)了
3 回答

錯(cuò)過(guò)了年華
TA貢獻(xiàn)56條經(jīng)驗(yàn) 獲得超22個(gè)贊
你的name="1score"和isset($_GET['lscore']都不對(duì)應(yīng)。仔細(xì)檢查,有些是數(shù)字1,有些是字母l。
ps:最好不要用l和1,不便于檢查出錯(cuò)誤
value還可以等于"<?php?if(!empty($_POST["lscore"])){echo?$_GET["lscore"];}??>" ? ??
還沒(méi)學(xué)到,這是什么用法?
- 3 回答
- 0 關(guān)注
- 1319 瀏覽
添加回答
舉報(bào)
0/150
提交
取消