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

PHP判断程序小问题,逻辑问题

PHP判断程序小问题,逻辑问题

PHP
侠客岛的含笑 2016-10-27 13:07:08
<!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>无标题文档</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 = "姓名不能为数字";                 } else {                     if (isset($_GET['lscore'])) {                         $score = $_GET['lscore'];                         if (empty($score)) {                             $str = "成绩不能为空";                         } else {                             if (is_numeric($score)) {                                 if ($score < 0 || $score > 100) {                                     $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>不能判断成绩,求告诉我哪里错了
查看完整描述

3 回答

?
错过了年华

TA贡献56条经验 获得超22个赞

你的name="1score"和isset($_GET['lscore']都不对应。仔细检查,有些是数字1,有些是字母l。

ps:最好不要用l和1,不便于检查出错误

value还可以等于"<?php if(!empty($_POST["lscore"])){echo $_GET["lscore"];} ?>"    ?

还没学到,这是什么用法?

查看完整回答
反对 回复 2016-11-13
  • 3 回答
  • 0 关注
  • 1288 浏览

添加回答

举报

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