douxuelv7755 2014-03-19 14:18
浏览 35
已采纳

PHP-如果语句未评估为true,尽管被比较的值在逻辑上被验证为真

The value of valid is coming from another page after redirection.In the address bar the value of valid=%273%27. The value is echoing as '3', but still the if statement is evaluating to false.In the database table i have declared the type for variable valid as INT. I have tried changing the type for variable valid into TINYINT and ENUM and VARCHAR also,but to no use.

<?php
     $output="";
     if($_GET['valid']==3)
     {
                $output.="<br/><br/><br/>
                <h2>You are just one step behind completing your Profile.Please Upload Your Photo Here:</h2>
                <br/><br/><br/>";
               $output.="<form action=\"loadStudent.php\" method=\"post\" enctype=\"multipart/form-data\">";
                $output.="<table>";
                $output.="<tr>";
        $output.="<td align=\"right\"><font size=\"2\" face=\"Arial\"><strong>Picture</strong></font></td>";
         $output.="<td align=\"center\">:</td>";
         $output.="<td>";
         $output.="<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"10485760\">";
         $output.="<input type=\"file\" name=\"image\"  id=\"file\" size=\"255\"> <font size=\"5\" face=\"Arial\"> Maxsize 1MB</font>";
         $output.="</td>";
       $output.="</tr>";
      $output.="<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</td></tr>
                    <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</td><td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Submit\"></td>";
                    $output.=" </tr>";
                     $output.="</table>";
                 $output.="</form>";
                 echo $userId;
    echo $output;   

    }//if($valid==3)
    echo $_GET['valid'];
    ?>
  • 写回答

3条回答 默认 最新

  • doubi8383 2014-03-19 14:26
    关注

    if you see valid=%273%27 , it means that you are sending '3' with the single quote.

    You could check for the value "'3'"

    if($_GET['valid']=="'3'")
    

    or remove it from the input

    $valid = intval(str_replace("'",'',$_GET['valid']));
    if ($valid == 3)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等