duanping2809 2014-06-25 16:31
浏览 18
已采纳

检查登录时是否未激活激活码。 “仅”激活码

This is the code I use at login:

            $q = $lacz->query("SELECT email, pass, activation_code
                                    FROM users
                                    WHERE  email='". $nazwa_uz_l ."' 
                                    AND pass = '". $haslo_l ."' 
                                    AND activation_code IS NULL ");     

        if($q->num_rows>0) {
            $_SESSION['prawid_uzyt'] = $nazwa_uz_l; }
        else 
        {
            echo 'Pass or Log are wrong, or activation code is not confirmed (check email).';
            exit;
        }

In this query I check for all 3 things: email, password and activation code, and then output an error. What I want to do is to output an first error when Pass or Log are wrong and second error (something like elseif) when activation code IS not NULL. I tried else if and two queries, but I was getting the errors. Can You help me? I check the answers and give points, thanks.

  • 写回答

3条回答 默认 最新

  • dongnao9525 2014-06-25 16:40
    关注

    Remove "AND activation_code IS NULL" from your query and do something like

    if($q->num_rows>0) 
    {
      $row = $q->fetch_assoc();
      if(!is_null($row['activation_code']))
      {
        $_SESSION['prawid_uzyt'] = $nazwa_uz_l;
      }
      else 
      {
        echo 'Activation code is not confirmed (check email).';
        exit;
      }
    }
    else 
    {
      echo 'Pass or Log are wrong.';
      exit;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度