为了账号安全,请及时绑定邮箱和手机立即绑定

Php判断成绩逻辑小问题?不会,求大神

Php判断成绩逻辑小问题?不会,求大神

PHP
侠客岛的含笑 2016-10-27 11:50:28
<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.imooc.com/wenda/detail/333114原问题连锁
查看完整描述

1 回答

已采纳
?
慕仙5610752

TA贡献20条经验 获得超2个赞


1,一个建议,表单接收数据后最好action到一个新页面做各种判断

2,method中用的get方式,怎么又判断post方式的数据呐,你可以用post方式,在接收表单数据的页面中用post接收,然后

判断,然后输出。


查看完整回答
1 反对 回复 2016-10-27
  • 1 回答
  • 0 关注
  • 1416 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信